缓存技术

1,缓存是在内存中保存创建代价高的信息副本的一种技术,它可以同时提高性能和扩展性。

2,缓存的分类:a,静态文件缓存

       b,动态缓存:

                   (1)传统缓存方式

       (2)页面输出缓存

3,

1 System.Web.Caching.CacheDependency dep=new Syste.Web.Caching.CacheDependency("C:\text.txt");
2 SetCache(Cachekey,objModel,dep); //objModel:缓存对象

4,在web.config的<system.web>节中写入:

<caching>
     <sqlCacheDependency enabled="true" pollTime="6000">
         <databases>
 <add naem="codematic" connectionStringName="strcodematic"/>
       </databases>
     </sqlCacheDependency >
 </caching>    

5,第三方缓存系统(Cache Application Block,Memcached,Cacheman)

6,缓存后替换

方法:以声明方式使用Substitution控件

    以编程方式使用Substitution控件API

    以隐式方式使用控件

7、应用程序数据缓存:system.Web.Caching命名空间提供用于缓存服务器上的常用的数据类,该命名空间包含Cache类,该类是一个字典,

8、文件缓存依赖:让缓存依赖于一个指定的文件,通过改变文件的更新日期来清除缓存

9、数据库缓存依赖

  (1)修改web.config,让项目启用SqlCacheDependency

   (2)执行下述命令,为数据库启用缓存依赖

aspent_regsql -C "data source=.;initial catalog=BOOKDB;user id=sa;pwd=123456" -ed -et -t "BookInfo"

   (3)在代码中使用缓存,并为其设置SqlCacheDependency依赖

 

原文地址:https://www.cnblogs.com/dclcc/p/3485820.html