如何在 nhibernate 中为 syscache 配置缓存区域?

Isa*_*ger 3 c# nhibernate syscache

我尝试使用网站上的这篇文章这样的缓存配置:

<configSections>
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" requirePermission="false"/>
    <section name="syscache" type="NHibernate.Caches.SysCache.SysCacheSectionHandler, NHibernate.Caches.SysCache" requirePermission="false" />
</configSections>

<!-- NHibernate -->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
        <!-- dialect, connection string, etc... -->

        <property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
        <property name="cache.use_second_level_cache">true</property>
    </session-factory>
</hibernate-configuration>

<!-- Caching -->
<syscache>
    <cache region="LongTerm" expiration="3600" priority="5" />
    <cache region="ShortTerm" expiration="900" priority="3" />
</syscache>

<-- ... -->
Run Code Online (Sandbox Code Playgroud)

不过,似乎我的 hibernate.cfg.xml 的架构文件不喜欢这个。我应该使用 cache.region_prefix 还是什么?我想使用 Syscache,顺便说一句。

Die*_*hon 5

您的 hibernate.cfg.xml 文件中既不包含configSections也不包含syscache部分。

他们进入App.config/Web.config文件。