/// <summary> /// Returns the response for the bundle from the cache if it exists, null otherwise /// </summary> /// <param name="context"></param> /// <param name="bundle"></param> /// <returns></returns> public BundleResponse Get(BundleContext context, Bundle bundle) { if (context == null) { throw new ArgumentNullException("context"); } return(context.HttpContext.Cache[bundle.GetCacheKey(context)] as BundleResponse); }
/// <summary> /// Stores the response for the bundle in the cache, also sets up cache depedencies for the virtual files /// used for the response /// </summary> /// <param name="context"></param> /// <param name="bundle"></param> /// <param name="response"></param> public void Put(BundleContext context, Bundle bundle, BundleResponse response) { List <string> paths = new List <string>(); paths.AddRange(response.Files.Select(f => f.VirtualFile.VirtualPath)); paths.AddRange(context.CacheDependencyDirectories); string cacheKey = bundle.GetCacheKey(context); // REVIEW: Should we store the actual time we read the files? CacheDependency dep = context.VirtualPathProvider.GetCacheDependency(context.BundleVirtualPath, paths, DateTime.UtcNow); context.HttpContext.Cache.Insert(cacheKey, response, dep); bundle.CacheKeys.Add(cacheKey); }