次のセットアップで outputCache がクリアされない理由を突き止めようとしています。
outputCacheItem をクリアするためにチェックしたほとんどすべてのリンクは、単に RemoveOutputCacheItem(string) メソッドを呼び出すように言っています。しかし、そうではないことがわかりました。デバッガーで一度メソッドを取得すると、ClearCacheName() に移動し、削除を実行します。その後、メソッドを再度ヒットすることはなく、キャッシュがスタックしているため、結果セットが永久にnullになることがわかりました。
[OutputCache(Duration = int.MaxValue, Location = OutputCacheLocation.Server)]
public JsonResult GetNames()
{
if (SomeResultSet != null)
{
var results =
SomeResultSet
.Where(x => x.LookupName != null)
.OrderBy(x => x.LookupName)
.Select(x => new
{
value = x.LookupName,
label = x.LookupName
}).Distinct();
return new JsonResult() {Data = results, JsonRequestBehavior = JsonRequestBehavior.AllowGet};
}
ClearCacheNames();
return null;
}
private void ClearCacheNames()
{
// OutputCacheAttribute.ChildActionCache = new MemoryCache(new Guid().ToString());
Response.RemoveOutputCacheItem(Url.Action("GetNames","Search",null));
}