Esempio 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;
 }
Esempio 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);
        }
        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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 public void SetSlidingExpiration(TimeSpan relative)
 {
     _context.SetSlidingExpiration(relative);
 }
Esempio n. 6
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);
        }