Exemplo n.º 1
0
 private object ConfigureEntry(ICacheSetContext context)
 {
     var value = (string)context.State;
     context.SetAbsoluteExpiration(TimeSpan.FromSeconds(7));
     context.SetSlidingExpiration(TimeSpan.FromSeconds(3));
     context.RegisterPostEvictionCallback(AfterEvicted, null);
     return value;
 }
Exemplo n.º 2
0
        private object ConfigureEntry(ICacheSetContext context)
        {
            var value = (string)context.State;

            context.SetAbsoluteExpiration(TimeSpan.FromSeconds(7));
            context.SetSlidingExpiration(TimeSpan.FromSeconds(3));
            context.RegisterPostEvictionCallback(AfterEvicted, null);
            return(value);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        // Internal for unit testing
        internal void UpdateCacheContext(ICacheSetContext cacheSetContext, EntryLink entryLink)
        {
            if (ExpiresOn != null)
            {
                cacheSetContext.SetAbsoluteExpiration(ExpiresOn.Value);
            }

            if (ExpiresAfter != null)
            {
                cacheSetContext.SetAbsoluteExpiration(ExpiresAfter.Value);
            }

            if (ExpiresSliding != null)
            {
                cacheSetContext.SetSlidingExpiration(ExpiresSliding.Value);
            }

            if (Priority != null)
            {
                cacheSetContext.SetPriority(Priority.Value);
            }

            cacheSetContext.AddEntryLink(entryLink);
        }
 internal LocalContextWrapper(ICacheSetContext context)
 {
     _context = context;
 }
Exemplo n.º 9
0
 internal LocalContextWrapper(ICacheSetContext context)
 {
     _context = context;
 }
Exemplo n.º 10
0
        // Internal for unit testing
        internal void UpdateCacheContext(ICacheSetContext cacheSetContext, EntryLink entryLink)
        {
            if (ExpiresOn != null)
            {
                cacheSetContext.SetAbsoluteExpiration(ExpiresOn.Value);
            }

            if (ExpiresAfter != null)
            {
                cacheSetContext.SetAbsoluteExpiration(ExpiresAfter.Value);
            }

            if (ExpiresSliding != null)
            {
                cacheSetContext.SetSlidingExpiration(ExpiresSliding.Value);
            }

            if (Priority != null)
            {
                cacheSetContext.SetPriority(Priority.Value);
            }

            cacheSetContext.AddEntryLink(entryLink);
        }