是否可以在所有使用[OutputCache]
修饰的控制器上找到所有Action方法,以便我可以通过它们枚举来一次性从缓存中删除selected
个项目?
foreach(var .. in ...)
{
//get ActionName
//get ControllerName
HttpResponse.RemoveOutputCacheItem(Url.Action(ActionName, ControllerName));
}
根据此post,无法一次性使缓存失效。
修改看起来我只需执行此操作即可使ALL
缓存无效: -
public ActionResult Invalidate()
{
OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
return View();
}
有关详细信息,请参阅此post。然而,取决于控制器名称等,使高速缓存的部分无效将是很好的。
答案 0 :(得分:1)
看起来像
public ActionResult Invalidate()
{
OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
return View();
}
已经成功了......