public string GenerateETag(ControllerContext context, string absolutePath) { // If the content is cached, so is the ETag var etag = Depot.StringCache.Get( string.Format("etag_{0}", absolutePath) ); if (!string.IsNullOrWhiteSpace(etag)) { return(etag); } if (!System.IO.File.Exists(absolutePath)) { return("\"404\""); } etag = BuildETagFromPath(context, absolutePath); if (etag != null) { var etagDependency = new DefaultFileCacheDependency(); etagDependency.FilePaths.Add(absolutePath); Depot.StringCache.Add(string.Format("etag_{0}", absolutePath), etag, etagDependency); } return(etag); }
private static byte[] CacheOnServer(string absolutePath, string dependencyPath) { var contentDependency = new DefaultFileCacheDependency(); contentDependency.FilePaths.Add(dependencyPath); var content = System.IO.File.ReadAllBytes(absolutePath); Depot.ContentCache.Add(absolutePath, content, contentDependency); return(content); }
private static string LoadOrGetCachedTemplate(string location) { // TODO use that funky cache func thing string template = Cache.Get <string>(location); if (template == null) { if (File.Exists(location)) { template = File.ReadAllText(location); var dependency = new DefaultFileCacheDependency(); dependency.FilePaths.Add(location); Cache.Add(location, template, dependency); } } return(template); }
public void SetUp() { Cache = new DefaultCache(); FileCacheDependency = new DefaultFileCacheDependency(); }