public virtual IServerCache Create(WebPageContext context) { var value = context.GetConfigValue <string>("Page", "ServerCache", string.Empty).ToLower(); if (!string.IsNullOrEmpty(value)) { switch (value) { case "forever": return(ForeverServerCache.Instance); case "delay": return(DelayServerCache.Instance); default: return(NonServerCache.Instance); } } //通过后缀名获取 IServerCache cache = null; if (_caches.TryGetValue(context.PathExtension, out cache)) { return(cache); } return(NonServerCache.Instance); }
public virtual ICacheStorage CreateStorage(WebPageContext context) { var value = context.GetConfigValue <string>("Page", "CacheStorage", string.Empty).ToLower(); if (!string.IsNullOrEmpty(value)) { return(CacheStorageFactory.Create(value)); //通过存储器名称获取 } //通过后缀名获取 ICacheStorage storage = null; if (_storages.TryGetValue(context.PathExtension, out storage)) { return(storage); } return(StorageEmpty.Instance); }
public ICompressor Create(WebPageContext context) { var value = context.GetConfigValue <string>("Page", "compressor", string.Empty).ToLower(); if (!string.IsNullOrEmpty(value)) { switch (value) { case "gzip": return(HttpCompressor.Instance); default: return(NonCompressor.Instance); } } //如果没有页面级配置,那么根据扩展名查看配置 ICompressor compressor = null; if (_compressors.TryGetValue(context.PathExtension, out compressor)) { return(compressor); } return(NonCompressor.Instance); }
private int GetCacheMinutes(WebPageContext context) { return(context.GetConfigValue <int>("Page", "delay", 0)); }