ASP.NET MVC. How to clear values cached by [OutputCacheAttribute]

对着背影说爱祢 提交于 2019-12-25 02:22:58

问题


I use [OutputCacheAttribute] to cache some actions. Everything works fine. Let's say I set its Duration property to 1 hour. But I want to be able to clear cached values. Is it possible?


回答1:


After looking at [OutputCacheAttribute] source code, it seems that the only possible solution is to implement a new class derived from MemoryCache and set it OutputCacheAttribute.ChildActionCache property. This class will be use some custom prefix for all cached keys, so I'll be quite easy to find them (and then remove from cache).



来源:https://stackoverflow.com/questions/7117216/asp-net-mvc-how-to-clear-values-cached-by-outputcacheattribute

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