protected async Task <IActionResult> CacheContentAsync <T>( CategoryCached category, string key, Func <Task <T> > dataLoader, RequestOptions options) { if (!cachePolicy.CanCache(category, options)) { return(Json(await dataLoader())); } string json; if (!string.IsNullOrEmpty(json = contentCache.GetContent(key))) { return(JsonString(json)); } var content = await dataLoader(); contentCache.CacheContent(key, json); return(JsonString(json)); }
protected async Task <IActionResult> CacheContentAsync <T>( CategoryCached category, string key, Func <Task <T> > dataLoader, int?page) { if (!cachePolicy.CanCache(category, page)) { return(Json(await dataLoader())); } string json; if (!string.IsNullOrEmpty(json = contentCache.GetContent(key))) { return(JsonString(json)); } var content = await dataLoader(); json = SunJson.Serialize(content); contentCache.CacheContent(key, json); return(JsonString(json)); }