c# - ASP 中的 Cache.NoSlidingExpiration - 何时重置?

标签 c# asp.net caching

我找到了类似问题的答案 ( 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.

这意味着当您调用 AddInsert 时,无论您在该调用中提供的 absoluteExpiration 值将用于使该项目过期.所以在你的例子中:

DateTime.Now.AddMinutes(20)

表示该项目将在 20 分钟后重置。

关于c# - ASP 中的 Cache.NoSlidingExpiration - 何时重置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7594597/

相关文章:

c# - 学习 Active Directory 操作的好网站

ruby-on-rails - 什么会导致 Rails 页面缓存停止工作?

.htaccess - 浏览器缓存工作除了 svg-images

c# - 任何 'quick wins' 都可以使 .NET 远程处理在一台机器上更快?

c# - 代码中的访问控制属性

C# 对象在构造函数外构造

Java IdentityHashMap 的 C# 等价物

ASP.NET网站部署最佳实践资源建议

asp.net - 从 Web API 的不记名 token 返回用户角色

即使我设置了条件,Spring Cache也不会忽略Null键