【问题标题】:ASP.NET MVC. How to clear values cached by [OutputCacheAttribute]ASP.NET MVC。如何清除 [OutputCacheAttribute] 缓存的值
【发布时间】:2013-01-21 19:02:45
【问题描述】:

我使用 [OutputCacheAttribute] 来缓存一些动作。一切正常。假设我将其 Duration 属性设置为 1 小时。但我希望能够清除缓存的值。有可能吗?

【问题讨论】:

标签: asp.net-mvc caching


【解决方案1】:

看了[OutputCacheAttribute]源代码后,似乎唯一可能的解决方案是实现一个从MemoryCache派生的新类并设置它OutputCacheAttribute.ChildActionCache属性。这个类将为所有缓存的键使用一些自定义前缀,所以我很容易找到它们(然后从缓存中删除)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-19
    • 1970-01-01
    • 2013-05-08
    相关资源
    最近更新 更多