예제 #1
0
        public Template GetTemplate(Context context, string templateName)
        {
            var virtualPath = ResolveVirtualPath(context, templateName);

            if (virtualPath.IsEmpty())
            {
                return(null);
            }

            var cacheKey       = HttpRuntime.Cache.BuildScopedKey("LiquidPartial://" + virtualPath);
            var cachedTemplate = HttpRuntime.Cache.Get(cacheKey);

            if (cachedTemplate == null)
            {
                // Read from file, compile and put to cache with file dependeny
                var source = ReadTemplateFileInternal(virtualPath);
                cachedTemplate = Template.Parse(source);
                var cacheDependency = _vpp.GetCacheDependency(virtualPath, DateTime.UtcNow);
                HttpRuntime.Cache.Insert(cacheKey, cachedTemplate, cacheDependency);
            }

            return((Template)cachedTemplate);
        }
예제 #2
0
 public static CacheDependency GetCacheDependency(this IVirtualPathProvider vpp, string virtualPath, DateTime utcStart)
 {
     return(vpp.GetCacheDependency(virtualPath, new[] { virtualPath }, utcStart));
 }