asp.net 将设有过期策略的项添加到缓存中

  下面的代码示例将有一分钟绝对过期时间的项添加到缓存中:

  

复制代码 代码如下:

  Cache.Insert("CacheItem6", "Cached Item 6",

  null, DateTime.Now.AddMinutes(1d),

  System.Web.Caching.Cache.NoSlidingExpiration);

  下面的代码示例将有 10 分钟弹性过期时间的项添加到缓存中:

  

复制代码 代码如下:

  Cache.Insert("CacheItem7", "Cached Item 7",

  null, System.Web.Caching.Cache.NoAbsoluteExpiration,

  new TimeSpan(0, 10, 0));