首页 > Web开发 > 详细

使用ASP.NET 的缓存机制的示例

时间:2015-05-12 11:02:11      阅读:197      评论:0      收藏:0      [点我收藏+]
if (HttpContext.Current.Cache["code_" + CodeType] == null)
{
  SysCodeService codeService = new SysCodeService();
  List<SysCodeInfo> allCode = codeService.GetCodeListByFlag(CodeType); HttpContext.Current.Cache.Add("code_" + CodeType, allCode, null, DateTime.MaxValue, new TimeSpan(0, 10, 0), System.Web.Caching.CacheItemPriority.Default, null)
}
var dataSource = ((List<SysCodeInfo>)HttpContext.Current.Cache["code_" + CodeType]);

对业务类查询的结果缓存10分钟,如果10分钟之内再次访问,直接读取缓存中的数据

 

使用ASP.NET 的缓存机制的示例

原文:http://www.cnblogs.com/babietongtianta/p/4496410.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!