2010-12-07 39 views
0

我正在尋找一個緩存過濾器,可以在執行某些操作時將其刪除。 假設添加/刪除緩存作爲控制器上的過濾器

我有索引行動是加載記錄和緩存與過濾器一分鐘。 只要我打電話索引行動必須被緩存,並沒有去分貝。

一旦我在創建操作中創建一條記錄,它應該刪除緩存從數據庫加載記錄。

有沒有解決方案。 我在Ninject網絡示例中找到了一個,如下所示。我正在尋找相同的解決方案。

[Cache(0, 0, 5, 0)] 
public ActionResult Index() 
{ 
    //Code here.... 
} 

[HttpPost] 
[ClearCacheOnSuccess("Index")] 
public ActionResult Create(string confirmButton, CreateViewModel userVm) 
{ 
    //Code here... 
} 

回答

0

根據您的緩存持久化(服務器或客戶端),你可以使用RemoveOutputCacheItem方法:

var urlToRemove = Url.Action("Index", "Home"); 
Response.RemoveOutputCacheItem(urlToRemove);