ASP.NET MVC. How to clear values cached by [Output

2019-09-15 07:53发布

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条回答
女痞
2楼-- · 2019-09-15 08:51

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).

查看更多
登录 后发表回答