码迷,mamicode.com
首页 > Web开发 > 详细

asp.net 缓存Cache的使用总结

时间:2017-06-30 12:33:40      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:color   second   web   div   abs   使用   logs   class   runtime   

1).获取缓存值
object o = HttpRuntime.Cache.Get("Key");
2).设置相对过期缓存值有两种写法
第一种:
HttpRuntime.Cache.Insert("Key", "Value", null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(30));
第二种:
HttpRuntime.Cache.Insert("Key","Value", null, DateTime.MaxValue, TimeSpan.FromSeconds(30));
3)设置绝对过期缓存值两种写法
HttpRuntime.Cache.Insert("Key","Value",null,DateTime.Now.AddMinutes(10),System.Web.Caching.Cache.NoSlidingExpiration);
第二种:
HttpRuntime.Cache.Insert("Key", "Value", null, DateTime.Now.AddMinutes(10), TimeSpan.Zero);
3)移除缓存
HttpRuntime.Cache.Remove("Key");

 

asp.net 缓存Cache的使用总结

标签:color   second   web   div   abs   使用   logs   class   runtime   

原文地址:http://www.cnblogs.com/Cein/p/7097921.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!