how to enable sql dependency output cache

    how to enable sql dependency output cache :

  • 注册 sql cache dependency

 

其实它的实现原理很简单, 会在系统中增加一些SP和trigger,来跟踪和记录表的变化

 

      这个是让我想起了,Leyser Service实现本地库和DataCenter数据同步的机制,简直是如出一辙,不过我们的Leyser 系统实现得比它更早。

  • 在web.config文件的<system.web>节点下增加:

 <caching>
   <sqlCacheDependency enabled="true" pollTime="2000">
    <databases>
     <add name="NW" connectionStringName="NorthwindConnectionString1"/>
    </databases>
   </sqlCacheDependency>
  </caching>

 <connectionStrings>
  <add name="NorthwindConnectionString1" connectionString="Data Source=xa-app-xsweb/sqlexpress;Initial Catalog=Northwind;User ID=sa;Password=******" providerName="System.Data.SqlClient"/>
 </connectionStrings>

NorthwindConnectionString1 是在connectionStrings中配置的数据库连接串。

  • 在对应的aspx页面增加page directive :

                     <%@ OutputCache Duration="20" VaryByParam="*" SqlDependency="NW:Customers"%>

  • ruan your target page


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值