4

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");

私は何を間違っていますか?

4

1 に答える 1

3

私は解決策を見つけました

パラメータに大文字を含めることはできないようです。これは既知のバグであり、修正される予定です。

product_Id を product_id に変更すると機能します。

于 2012-01-28T10:03:10.127 に答える