我尝试使用来自网站的这篇文章的缓存配置:
<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>
<-- ... -->
不过,我的 hibernate.cfg.xml 的模式文件似乎不喜欢这样。我应该使用 cache.region_prefix 还是什么?顺便说一下,我想使用 Syscache。
最佳答案
configSections
和 syscache
部分都不在您的 hibernate.cfg.xml 文件中。
它们进入 App.config
/Web.config
文件。
关于c# - 我如何在 nhibernate 中为 syscache 配置缓存区域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3214825/