IIS 和 ASP.NET 缓存
我创建了一个使用经典 ASP.NET 缓存的网站:
DataSet ds = new DataSet();
ds = (DataSet) Cache["MyDataSet"];
在 ASP.NET 代码中,我将持续时间设置为几个小时,但 IIS 会更早地重置缓存。
在 IIS 中,我可以在哪里手动设置 ASP.NET 缓存的持续时间?
我有足够的 RAM,具有满载的缓存和工作站点,我还有大约 1/3 的可用空间(总共 3GB,Web Server 2008R2)。
(我在缓存中进行了大量计算(几分钟),并且在工作期间我只更新缓存的一小部分)
I've created a web site that uses classic ASP.NET caching:
DataSet ds = new DataSet();
ds = (DataSet) Cache["MyDataSet"];
In ASP.NET code, I've set the duration for several hours, however IIS resets cache much earlier.
In IIS, where can I manually set the duration of ASP.NET caching?
I have enough RAM, with fully loaded cache and working sites I have about 1/3 free (3GBtotal, Web Server 2008R2).
(I have heavy calculations (several minutes) that are in cache, and during work I update only small parts of cache)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了测试您的元素何时自动从缓存中删除,您可以在发生这种情况时收到通知:ASP.NET 为此提供了 CacheItemRemovedCallback 委托。 Cache.Insert 语句具有重载,因此您可以编写类似的内容
(不确定我是否 100% 正确),然后由业务对象中的 ObjectRemovedCallback 方法进行处理。检查http://msdn.microsoft.com/en-us/library/7kxdx246。 aspx 了解更多详细信息。您很有可能在这里找到缓存过早过期的原因。
In order to test when your element gets automatically removed from your cache, you can get notified when that happens: ASP.NET provides the CacheItemRemovedCallback delegate for that purpose. The Cache.Insert statement has an overload, so you can write something like
(not sure if I got that 100% right) and then have that handled by a ObjectRemovedCallback method in a business object. Check http://msdn.microsoft.com/en-us/library/7kxdx246.aspx for more details. There is a good chance that you can find out the reason for your premature cache expiration here.
将对象添加到Cache时,可以指定过期策略(绝对、滑动过期)。
请参阅此处了解更多详细信息解释。
以下是对象可能从缓存中删除的一些原因:
When you add the object to the Cache, you can specify the expiration policy (absolute, sliding expiration).
See here for a more detailed explanation.
Here's some reasons why an object may be removed from Cache: