예제 #1
0
        private CompilerCacheEntry PopulateCacheSetContext(ICacheSetContext cacheSetContext)
        {
            var entry = (CompilerCacheEntry)cacheSetContext.State;

            cacheSetContext.AddExpirationTrigger(_fileProvider.Watch(entry.RelativePath));

            var globalImportPaths = ViewHierarchyUtility.GetGlobalImportLocations(cacheSetContext.Key);

            foreach (var location in globalImportPaths)
            {
                cacheSetContext.AddExpirationTrigger(_fileProvider.Watch(location));
            }

            return(entry);
        }
예제 #2
0
        private PrecompilationCacheEntry OnCacheMiss(ICacheSetContext cacheSetContext)
        {
            var fileInfo = (RelativeFileInfo)cacheSetContext.State;
            var entry    = GetCacheEntry(fileInfo);

            if (entry != null)
            {
                cacheSetContext.AddExpirationTrigger(_fileProvider.Watch(fileInfo.RelativePath));
                foreach (var viewStartPath in ViewStartUtility.GetViewStartLocations(fileInfo.RelativePath))
                {
                    cacheSetContext.AddExpirationTrigger(_fileProvider.Watch(viewStartPath));
                }
            }

            return(entry);
        }
예제 #3
0
        /// <summary>
        /// Adds inherited trigger and absolute expiration information.
        /// </summary>
        /// <param name="link"></param>
        public static void AddEntryLink(this ICacheSetContext context, IEntryLink link)
        {
            foreach (var trigger in link.Triggers)
            {
                context.AddExpirationTrigger(trigger);
            }

            if (link.AbsoluteExpiration.HasValue)
            {
                context.SetAbsoluteExpiration(link.AbsoluteExpiration.Value);
            }
        }
예제 #4
0
        private CodeTree OnCacheMiss(ICacheSetContext cacheSetContext)
        {
            var pagePath    = cacheSetContext.Key;
            var getCodeTree = (Func <IFileInfo, CodeTree>)cacheSetContext.State;

            // GetOrAdd is invoked for each _ViewStart that might potentially exist in the path.
            // We can avoid performing file system lookups for files that do not exist by caching
            // negative results and adding a Watch for that file.
            cacheSetContext.AddExpirationTrigger(_fileProvider.Watch(pagePath));
            cacheSetContext.SetSlidingExpiration(SlidingExpirationDuration);

            var file = _fileProvider.GetFileInfo(pagePath);

            return(file.Exists ? getCodeTree(file) : null);
        }