IDに基づいてキャッシュしたいActionResultがあります
[DonutOutputCache(Duration = 3600, VaryByParam = "product_Id")]
public ActionResult ProductInfo(Guid product_Id)
{
System.Threading.Thread.Sleep(3000);
return PartialView(_repository.GetProductInfo(product_Id));
}
それはうまくいっています。
キャッシュを削除したいときは、この構文を使用します
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SaveDetails(DetailsModel model)
{
try
{
// save action here, then remove cache
var cacheManager = new OutputCacheManager();
cacheManager.RemoveItem("Common", "ProductInfo", new { product_Id = model.Product_Id });
return Json(new { hasError = false }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
return Json(new { hasError = true, message = ex.Message }, JsonRequestBehavior.AllowGet);
}
}
パラメータを指定すると、OutputCacheManager().RemoveItem が機能しません。
使用するだけで機能します
cacheManager.RemoveItem("Common", "ProductInfo");
私は何を間違っていますか?