zoukankan      html  css  js  c++  java
  • asp.net2.0 缓存:数据库依赖

    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";
            }

  • 相关阅读:
    六、Linux计划任务及压缩归档
    四、用户管理
    三、vim编辑器详解
    八、RAID磁盘阵列及CentOS7系统启动流程
    五、权限管理
    二、Linux常用命令
    七、Linux磁盘管理及LVM讲解
    一、Linux常用命令
    JS继承的实现方式 原型 原型链 prototype和_proto_的区别
    js引用类型(Object、Array)
  • 原文地址:https://www.cnblogs.com/silva/p/692835.html
Copyright © 2011-2022 走看看