HttpContext.Current.Cache过期使用方法

// absoluteExpiration: // 所插入对象将过期并被从缓存中移除的时间。 // 如果使用绝对过期,则 slidingExpiration 参数必须为 Cache.NoSlidingExpiration。 // // slidingExpiration: // 最后一次访问所插入对象时与该对象过期时之间的时间间隔。如果该值等效于 20 分钟, // 则对象在最后一次被访问 20 分钟之后将过期并被从缓存中移除。如果使用可调过期,则 // absoluteExpiration 参数必须为 System.Web.Caching.Cache.NoAbsoluteExpiration。

如:HttpContext.Current.Cache.Insert(token,clientIp, null, Cache.NoAbsoluteExpiration, TimeSpan.FromHours(2));
表示最后一次访问缓存后两个小时过期。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章