Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public void SetUp()
 {
     Cache = new DefaultCache();
     FileCacheDependency = new DefaultFileCacheDependency();
 }