Ejemplo 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;
 }
Ejemplo 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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo 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);
        }
Ejemplo n.º 5
0
 public void SetSlidingExpiration(TimeSpan relative)
 {
     _context.SetSlidingExpiration(relative);
 }
Ejemplo 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);
        }