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

  • 相关阅读:
    delphi字符串固定长度换行
    delphi存取图片
    fastreport字体加粗
    delphi 连接oracle对接代码
    Trystrtofloat
    去掉整数前面多余的0
    查询字符串第一次出现的数字
    字符串
    详细理解servlet实现的三种方式和生命周期
    Tomcat源码解析-整体流程介绍
  • 原文地址:https://www.cnblogs.com/silva/p/692835.html
Copyright © 2020-2023  润新知