asp.net2.0 缓存:数据库依赖
2007-03-29 15:19
555 查看
Web.config
<configuration>
<appSettings/>
<connectionStrings>
<add name="TestConnectionString" connectionString="server=shgpc150\sql2k;database=Northwind;uid=sa;pwd=;"></add>
</connectionStrings>
<system.web>
<caching>
<sqlCacheDependency enabled="true" pollTime="1000">
<databases>
<add name="Northwind" connectionStringName="TestConnectionString" pollTime="1000"></add>
</databases>
</sqlCacheDependency>
</caching>
............
Page_Load.
System.Web.Caching.SqlCacheDependencyAdmin.EnableNotifications(System.Configuration.ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString);
System.Web.Caching.SqlCacheDependencyAdmin.EnableTableForNotifications(System.Configuration.ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString, "Employees");
if (HttpContext.Current.Cache["dsEmpployees"] == null)
{
System.Web.Caching.SqlCacheDependency depe = new System.Web.Caching.SqlCacheDependency("Northwind", "Employees");
HttpContext.Current.Cache.Insert("dsEmpployees", "dsEmpployees", depe);
Label1.Text = "new cache generated!";
}
else
{
Label1.Text = "Load data from cache";
}
<configuration>
<appSettings/>
<connectionStrings>
<add name="TestConnectionString" connectionString="server=shgpc150\sql2k;database=Northwind;uid=sa;pwd=;"></add>
</connectionStrings>
<system.web>
<caching>
<sqlCacheDependency enabled="true" pollTime="1000">
<databases>
<add name="Northwind" connectionStringName="TestConnectionString" pollTime="1000"></add>
</databases>
</sqlCacheDependency>
</caching>
............
Page_Load.
System.Web.Caching.SqlCacheDependencyAdmin.EnableNotifications(System.Configuration.ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString);
System.Web.Caching.SqlCacheDependencyAdmin.EnableTableForNotifications(System.Configuration.ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString, "Employees");
if (HttpContext.Current.Cache["dsEmpployees"] == null)
{
System.Web.Caching.SqlCacheDependency depe = new System.Web.Caching.SqlCacheDependency("Northwind", "Employees");
HttpContext.Current.Cache.Insert("dsEmpployees", "dsEmpployees", depe);
Label1.Text = "new cache generated!";
}
else
{
Label1.Text = "Load data from cache";
}
相关文章推荐
- ASP.NET2.0结合aspnet_regsql实现数据库的缓存依赖
- SqlDependency建立数据库表依赖实现自动刷新缓存
- ASP.NET缓存之数据库缓存依赖(一)
- 数据库缓存依赖
- Asp.net数据库缓存依赖
- Android 开源项目android-open-project工具库解析之(一) 依赖注入,图片缓存,网络相关,数据库orm工具包,Android公共库
- Asp.net 数据库缓存依赖(SQLServer 2005)
- 转 数据库缓存依赖配置
- 缓存依赖(文件、数据库)
- 如何添加数据库的缓存依赖
- 六.数据库缓存依赖
- 数据库缓存依赖
- ASP 缓存数据库依赖
- ASP.NET 数据库缓存依赖
- Android 开源项目android-open-project工具库解析之(一) 依赖注入,图片缓存,网络相关,数据库orm工具包,Android公共库
- 不使用数据库缓存依赖项实现同样的功能[转]
- ASP.NET MVC 数据库依赖缓存的实现
- 使用 SQL 缓存依赖项,数据库缓存依赖 (附实例)
- asp.net缓存技术---数据库缓存依赖
- ASP.NET 数据库缓存依赖