您的位置:首页 > 数据库 > SQL

how to enable sql dependency output cache

2007-05-12 15:38 363 查看
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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: