Refresh Enterprise Library Cache After External App Updates It

别来无恙 提交于 2019-12-08 09:33:45

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/4316980/refresh-enterprise-library-cache-after-external-app-updates-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!