开发者

Delete HttpRuntime.Cache items from an other application

I have an admin application in which I manipulate my objects in the db, and a public asp.net mvc application which is mostly for viewing these objects.

I have implemented a simple caching for a few objects, which uses HttpRuntime.Cache.

I want to invalidate parts of the cache of the public application from the admin application.

The simplest solution was to make a ClearCache() action which clears every record in the cache when called.

But wouldn't it be better to utilize a caching which uses cache dependencies? I don't know which would be the best to use and how. I was thinking about an sql dependency, but since I'm doing the caching to skip sql queries I'm not sure that this would be fast.

Is checking sql cache dependencies slow? I wish to use the cached objects in a LOT of cases, checking for the sql depe开发者_开发知识库ndency each time does not sound good.


You can use CacheDependency for it.

If there are two separate applications. You can use file dependency option. (there is also cache key dependency option)

When you touch a specific file (may be just an empty file) from an application. The other application cache items which are depended upon the same file will be automatically expired.

You can use different files to expire different category of cache items.


I recommend to have SQL dependency cache per each table or select query for records that suppose to be treated together. You may consider to create separate cache entries for some partitions (e.g. if you have country specific data, keep each country data in a separate cache entry with appropriate SQL dependency).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜