2010-07-09 47 views
3

我试图用这样的帖子缓存配置从网站:如何在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> 

<-- ... --> 

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

回答

4

无论是configSections也不syscache部分在hibernate.cfg.xml文件中去。

他们走在App.config/Web.config文件。

+0

呀,于是我找到了!我可以同时使用这些还是只使用其中一种? 我的伙伴开始这个程序,我不知道他为什么不选择App.config文件路径 – 2010-07-09 17:36:33

+0

您可以同时使用(hibernate.cfg.xml的只是为NHibernate的核心员工,并为的app.config休息) – 2010-07-09 20:44:52

+0

谢谢!我会研究这一点。 – 2010-07-09 23:19:57