外部应用程序更新后刷新企业库缓存
经过几个月的断断续续的搜索后,我终于决定将其发布。
我们有一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,差不多就是这样了。企业库使用的缓存位于内存中,ASP.NET 和 Windows 服务应用程序都有不同的内存空间。当您更新其中一个中的缓存时,不会更新另一个中的缓存。
ASP.NET 应用程序中也存在该问题,但似乎这是一个只读缓存,并且您正在从服务执行写入。
您需要做的是创建一个两个应用程序域都可以共享的缓存,并且有很多方法可以做到这一点:
一般来说,您希望执行“分布式缓存”。为此,您应该阅读 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:
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