我找到了类似问题的答案 ( System.Web.Caching.Cache.NoSlidingExpiration in asp.net c# ) 并点击了链接,但我需要更具体的信息,但我找不到。
当您“访问”它时,NoSlidingExpiration 不会重置。但是,这是否意味着当您阅读它时?还是在你写的时候?
例如,如果我这样做
Cache.Insert("mykey", 42, null, DateTime.Now.AddMinutes(20), System.Web.Caching.Cache.NoSlidingExpiration);
然后 10 分钟后,我做了:
Cache.Insert("mykey", 42, null, DateTime.Now.AddMinutes(20), System.Web.Caching.Cache.NoSlidingExpiration);
再问一下,过期时间会不会调整?
谢谢!
最佳答案
根据 Cache.NoSlidingExpiration 上的 MSDN 文档
When used, this field sets the slidingExpiration parameter to the TimeSpan.Zero field, which has a constant value of zero. The cached item expires in accordance with the absoluteExpiration parameter associated with the Insert or Add method call.
这意味着当您调用 Add
或 Insert
时,无论您在该调用中提供的 absoluteExpiration
值将用于使该项目过期.所以在你的例子中:
DateTime.Now.AddMinutes(20)
表示该项目将在 20 分钟后重置。
关于c# - ASP 中的 Cache.NoSlidingExpiration - 何时重置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7594597/