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