的System.Web.Caching.Cache似乎并没有刷新自己的时间呢?

编程入门 行业动态 更新时间:2024-10-24 20:13:31
本文介绍了的System.Web.Caching.Cache似乎并没有刷新自己的时间呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用的System.Web.Caching.Cache 通过我的网站使用的组件。我已经设置了一些关键到期(绝对过期)为10秒(只用于调试)。我也设置在关键去除回调。

I am using System.Web.Caching.Cache in an assembly used by my website. I have set some key expiration (absolute expiration) to be 10 seconds (just for debugging). I have also set a callback upon key removal.

问题是,我看到缓存像20秒后刷新得到,而不是10。

The problem is that I see that the cache is getting refreshed after something like 20 seconds and not 10.

我使用 HttpRuntime.Cache 这一点。

有关这是为什么发生的任何建议?

Any suggestion for why is that happening ?

我想表现出code样品,它可以更加清楚:

I would like to show a code sample, which can shed more light:

public void OnUpdate(string key , CacheItemUpdateReason reason , out object expensiveObject , out CacheDependency dependency , out DateTime absoluteExpiration , out TimeSpan slidingExpiration) { using (StreamWriter sw = new StreamWriter(@"C:\temp\foo.txt",true)) { sw.WriteLine("Updated Cache at " + DateTime.UtcNow); } expensiveObject = 11; dependency = null; absoluteExpiration = DateTime.UtcNow.AddSeconds(3); slidingExpiration = Cache.NoSlidingExpiration; } protected void Page_Load(object sender, EventArgs e) { log.WriteInfo("Updated Cache", MethodBase.GetCurrentMethod()); Page.Cache.Insert("foo", (object)11, null, DateTime.UtcNow.AddSeconds(10), Cache.NoSlidingExpiration, new CacheItemUpdateCallback(OnUpdate)); }

在这里,我用 Page.Cache 。更新应该是每3秒。实际上它是每40秒执行,如下面的打印输出显示:

Here, i used Page.Cache. The update should be every 3 seconds. Actually it is performed every 40 seconds, as the below printout shows:

在2011年1月28日上午01时38分20秒更新缓存在2011年1月28日上午1时38分四十零秒更新缓存在2011年1月28日上午01时39分零零秒更新缓存在2011年1月28日上午1点39分20秒更新缓存在2011年1月28日上午01时39分四十零秒更新缓存在2011年1月28日上午一时40分00秒更新缓存在2011年1月28日上午1时40分20秒更新缓存在2011年1月28日上午01时40分40秒更新缓存在2011年1月28日上午01时41分00秒更新缓存在2011年1月28日上午1点41分20秒更新缓存在2011年1月28日上午01时41分四十秒更新缓存在2011年1月28日上午01点42分00秒更新缓存在2011年1月28日上午1时42分二十秒更新缓存在2011年1月28日上午一时42分40秒更新缓存

这可能是什么问题?

推荐答案

的内部缓存过期计时器只激发每20秒。

The internal cache expire timer only fires every 20 seconds.

我反映到 System.Web.Caching.CacheExpires

但后来发现它已经是SO

But then found it already is on SO

Changing ASP.NET缓存项过期的频率是多少?

更多推荐

的System.Web.Caching.Cache似乎并没有刷新自己的时间呢?

本文发布于:2023-11-10 02:12:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574054.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自己的   时间   Web   System   Cache

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!