How do I configure cache regions for syscache in nhibernate?

2.4k views Asked by At

I tried to use a cache configuration like this post from a website:

<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>

<-- ... -->

It seems the schema file for my hibernate.cfg.xml is not liking this, though. Am I supposed to use cache.region_prefix or something? I want to use Syscache, btw.

1

There are 1 answers

3
Diego Mijelshon On BEST ANSWER

Neither the configSections nor the syscache sections go in your hibernate.cfg.xml file.

They go in the App.config/Web.config file.