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 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); }
// 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); }
public void SetSlidingExpiration(TimeSpan relative) { _context.SetSlidingExpiration(relative); }
// 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); }