外部应用程序更新后刷新企业库缓存

发布于 2024-10-04 20:22:24 字数 277 浏览 10 评论 0原文

经过几个月的断断续续的搜索后,我终于决定将其发布。

我们有一个 ASP.NET MVC 应用程序,它使用企业库来缓存项目。我们还使用 Windows 服务来经常更新这些缓存的项目。问题是,当Windows服务更新缓存项时,mvc网站在我们重置IIS之前看不到更新的缓存项。我们曾考虑过在服务中放入一些代码来重新启动 IIS 服务,但认为必须有更好的方法。似乎还有另一篇文章讨论了从外部应用程序中删除项目,但它还不够深入。

我们认为这与缓存管理器每个实例本地的内存版本有关,但根本找不到将它们整合在一起的方法。

After searching around for months on and off I finally decided to post this up.

We have an ASP.NET MVC app that uses enterprise library to cache items. We also use a windows service that every so often updates those cached items. Problem is that when the windows service updates the cached items, the mvc website does not see the updated cached items until we reset IIS. We have thought about putting some code in the service to restart the IIS service but think there has got to be a better way. There seems to be one other post that talks about removing items from an external app, but it doesn't go far enough.

We think it has something to do with the in memory version that is local to each instance of the cache manager but simply cannot find a way to bring it all together.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拧巴小姐 2024-10-11 20:22:24

嗯,差不多就是这样了。企业库使用的缓存位于内存中,ASP.NET 和 Windows 服务应用程序都有不同的内存空间。当您更新其中一个中的缓存时,不会更新另一个中的缓存。

ASP.NET 应用程序中也存在该问题,但似乎这是一个只读缓存,并且您正在从服务执行写入。

您需要做的是创建一个两个应用程序域都可以共享的缓存,并且有很多方法可以做到这一点:

  • 将项目存储在两个应用程序域都可以轻松访问的共享持久性存储(文件系统、数据库等)中
  • 拥有缓存服务它将处理缓存项的更新,但您将查询(例如通过 WCF)缓存项。

一般来说,您希望执行“分布式缓存”。为此,您应该阅读 MSDN 杂志中标题为“路径上的分布式缓存”的文章到可扩展性”了解有关 .NET 中分布式缓存选项的更多信息

Well, that's pretty much it. The cache that is being used by the Enterprise Library is in-memory, and the ASP.NET and Windows Service applications both have different memory spaces. When you update the cache in one, you don't update the cache in the other.

The problem exists in the ASP.NET app as well, but it seems that this is a read-only cache, and you are performing the writes from the service.

What you need to do is create a cache that both app domains can share and there are many ways to do this:

  • Store the items in a shared persistance store (filesystem, database, etc) that both app domains can access easily
  • Have a cache service which will handle the updates of the cache items, but which you will query (through WCF, for example) for the cache items

In general, you are looking to perform "distributed caching". To that end, you should read the article in MSDN Magazine titled "Distributed Caching On The Path To Scalability" for more information on distributed caching options in .NET

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文