public async Task <IActionResult> CacheContentAsync <T>( ComponentServerCached component, IEnumerable <int> categoryIds, Func <Task <T> > dataLoader, int?page = null) { if (!cachePolicy.CanCache(component, page)) { return(Json(await dataLoader())); } var key = keyGenerator.ContentGenerateKey(component.Name, categoryIds, page); 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)); }
public bool CanCache(ComponentServerCached component, int?page = null) { return(false); }
public bool CanCache(ComponentServerCached component, int?page = null) { return(!page.HasValue || page == 1); }