/// <summary> /// Render bundle with a given name. /// </summary> /// <param name="name">Name for bundle.</param> /// <returns>HTML tag.</returns> public string RenderNamed(string name) { bundleState = GetCachedBundleState(name); if (!bundleState.DebugPredicate.SafeExecute()) { // Revisit https://github.com/jetheredge/SquishIt/pull/155 and https://github.com/jetheredge/SquishIt/issues/183 //hopefully we can find a better way to satisfy both of these requirements var fullName = (BaseOutputHref ?? "") + CachePrefix + name; var content = bundleCache.GetContent(fullName); if (content == null) { AsNamed(name, bundleState.Path); return(bundleCache.GetContent(CachePrefix + name)); } return(content); } return(RenderDebug(bundleState.Path, name, GetFileRenderer())); }
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)); }
/// <summary> /// Render cached 'raw' bundle content. /// </summary> /// <param name="bundleName">String representation of content according to cache.</param> /// <returns></returns> public string RenderCachedRawContent(string bundleName) { var cacheKey = CachePrefix + "_raw_" + bundleName; var output = rawContentCache.GetContent(cacheKey); if (output == null) { rawContentBundleStateCache.TryGetValue(cacheKey, out bundleState); if (bundleState == null) { throw new InvalidOperationException(string.Format("No cached bundle state named {0} was found.", bundleName)); } output = RenderRawContent(bundleName); } return(output); }