Using NCache with your NHibernate application is a multi-step process.
Installing and configuring NCache can be summarized into these steps:
For more details, watch a 7-minute NCache video on Five Steps to Getting Started.
To enable NCache as Level-2 provider for NHibernate, add the following lines to your app.config or web.config file:
<hibernate - configuration>
...
<session - factory>
...
<property name = "cache.provider_class">
Alachisoft.NCache.Integrations.NHibernate.Cache.NCacheProvider,
Alachisoft.NCache.Integrations.NHibernate.Cache
</property>
</session - factory>
</hibernate - configuration>
Now that you've configured NCache to become a Level-2 provider for NHibernate, you need to provide some NCache specific properties. These properties help NCache work with your application.
<configSections>
...
<section name = "ncache"
type = "Alachisoft.NCache.Integrations.NHibernate.Cache.NCacheSection,
Alachisoft.NCache.Integrations.NHibernate.Cache"/>
</configSections>
The above lines specify an "ncache" section for your config file. Now specify NCache properties in this "ncache" section.
<ncache>
<!--default regionis used if no other regions are specified.-->
<region name = " default ">
<add key = " cacheName " value = " myCache " />
<add key = " enableCacheException " value = " false " />
</region>
<!--see docs for custom regions & db - synchronization properties.-->
</ncache>
There are more NCache properties if you want to synchronize the cache with your database. See product documentation for more details.
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.