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));
表示最后一次访问缓存后两个小时过期。
原文地址:https://www.cnblogs.com/crazy29/p/6766981.html