Alachisoft NCache 4.1 - Online Documentation

Step 2: Register NCache with NHibernate

To register NCache with NHibernate, edit app.config or web.config as follows:
  1. Register 'nhibernate' and 'ncache' configuration sections in the <configSections> of the web.config or app.config as follows:
    <section name = "hibernate-configuration" type = "NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
    <section name = "ncache" type = "Alachisoft.NCache.Integrations.NHibernate.Cache.NCacheSection,
  2. Define section details for <nhibernate> as follows:
    <hibernate-configuration xmlns = "urn:nhibernate-configuration-2.2">
    <property name = "cache.provider_class" > Alachisoft.NCache.Integrations.NHibernate.Cache.NCacheProvider, Alachisoft.NCache.Integrations.NHibernate.Cache </property>
  3. Define section details for <ncache> as follows:
    <region name = "default">
    <add key = "cacheName " value =" mycache"/>
    <add key = "enableCacheException" value = "false"/>
    <class name = "nhibernator.BLL.Customer">
    <add key = "priority" value = "1"/>
    <add key = "useAsync" value = "false"/>
    <add key = "relativeExpiration" value = "180"/> or <add key = "staticExpiration" value = "100"/>
  • Calling new Configuration() only reads the <nhibernate> section.
  • Calling no-parameter version of cfg.Configure() configures NHibernate from app.config if it contains <nhibernate-configuration>, otherwise hibernate.cfg.xml is used.
    See Also

Copyright © 2005-2012 Alachisoft. All rights reserved.