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); }
/// <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); } }
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); }
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); }
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); }
// 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; }
internal LocalContextWrapper(ICacheSetContext context) { _context = context; }
// 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); }