开发者

How to invalidate cache when the file which is cached changes

I read few xml files from a location and cache them using Http context cache. Anytime the xml files changes i have to do a IISReset to view the latest changes.

I use this

System.Web.HttpContext.Current.Cache

I have to use the caching as i don't want to read all the xml files all the time. i read it once and caches them for a day. They get reset whene开发者_开发百科ver apppool recyles or anyone manualy do a IISReset.

Is there anyway in asp.net to invalidate the cache if someones changes the xml file.

I did search for google but couldn't get any relavent , any kind of direction is enough thanks.


If you look at Cache.Insert there is an overload for that method that takes a CacheDependency object. You can point this object to one or more files that the cache is dependant on and if these change the cache is invalidated.

See: (Was going to post the linkm but for some reason copy & paste stoped working here. If you search for Cache.Insert on msdn or let the intellisense help you I think you will find the information)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜