ASP.NET 数据缓存 - 应用域重启后保留内容 [英] ASP.NET Data Cache - preserve contents after app domain restart

查看:27
本文介绍了ASP.NET 数据缓存 - 应用域重启后保留内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ASP.NET 的数据缓存 API.例如:

I am using ASP.NET's data caching API. For example:

HttpRuntime.Cache.Insert(my_data, my_key);

有什么方法可以配置缓存,以便在应用程序域回收时保留其内容?

Is there any way to configure cache so its contents are preserved when the App Domain recycles?

我将许多对象加载到缓存中,但是每次应用程序域重新启动时重新加载这些对象都会有很大的延迟.对于这个问题,假设由于服务器配置,我无法阻止 appdomain 重新启动.

I load many object into cache, but there is a substantial delay re-loading these every time the app domain restarts. Assume for this question that I can't prevent the appdomain restart due to a server configuration.

推荐答案

有没有办法配置缓存其内容在应用域回收?

Is there any way to configure cache so its contents are preserved when the App Domain recycles?

没有.Cache 对象在 RAM 中保存引用.期间.

No. The Cache object holds references in RAM. Period.

替代方案:

  1. 进程外会话状态(尽管是针对每个用户的)
  2. 分布式缓存
  3. 将 SQL Server 用作缓存(将数据保存在内存中,而不是磁盘上)
  4. 在 Web 层将对象写入磁盘

我自己通常更喜欢 #3,尽管在某些情况下其他人是合适的.

I generally prefer #3 myself, although there are scenarios where the others are appropriate.

这篇关于ASP.NET 数据缓存 - 应用域重启后保留内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆