开发者

Find all action methods that have been decorated with [OutputCache] and remove

Is it possible to find all Action methods on all controllers that have been decorated with [OutputCache] so I can then enumerate through them to remove selected items from the cache in one go?

foreach(var .. in ...)
{
  //get ActionName
  //get ControllerName
  HttpResponse.RemoveOutputCacheItem(Url.Action(ActionName, ControllerName));
}

According to this post it is not possible to invalidate the cache in one go.

Edit It looks like I can invalidate the ALL the cache by simply doing this:-

public ActionResult Invalidate()
{
    OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
    return View();
}

See this post for more info. However it would be nice to inval开发者_如何学Goidate portions of the cache depending say on controller name etc.


Looks like

public ActionResult Invalidate()
{
    OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
    return View();
}

has done the trick...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜