如何快速使用 NCache 与NHibernate?

运用 NCache 使用您的 NHibernate 应用程序是一个多步骤的过程。

1.安装和配置 NCache 在应用服务器上

安装和配置 NCache 可以概括为以下几个步骤:

  1. Install 安装 NCache 在所有应用服务器和缓存服务器上
  2. 创建缓存集群
  3. 配置 remote clients
  4. 测试缓存集群
  5. 更多详情,请观看 7 分钟 NCache 视频开 入门的五个步骤.

2。 配置 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> 

3.指定 NCache NHibernate 的属性

现在你已经配置好了 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 如果要将缓存与数据库同步,请使用属性。 有关详细信息,请参阅产品文档。

接下来做什么?

联系我们

联系电话
©版权所有 Alachisoft 2002 - 版权所有。 NCache 是 Diyatech Corp. 的注册商标。