运用 NCache 使用您的 NHibernate 应用程序是一个多步骤的过程。
安装和配置 NCache 可以概括为以下几个步骤:
更多详情,请观看 7 分钟 NCache 视频开 入门的五个步骤.
启用 NCache 作为 NHibernate 的 Level-2 提供程序,将以下行添加到您的 app.config 或 web.config 文件中:
<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>
现在你已经配置好了 NCache 要成为 NHibernate 的 Level-2 提供者,您需要提供一些 NCache 具体属性。 这些属性有帮助 NCache 使用您的应用程序。
<configSections>
...
<section name = "ncache"
type = "Alachisoft.NCache.Integrations.NHibernate.Cache.NCacheSection,
Alachisoft.NCache.Integrations.NHibernate.Cache"/>
</configSections>
上面的行指定了一个“ncache" 配置文件的部分。现在指定 NCache 在这个“属性ncache“ 部分。
<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>
还有更多 NCache 如果要将缓存与数据库同步,请使用属性。 有关详细信息,请参阅产品文档。