public void InsertCacheItem(string cacheKey, Func <object> getCacheItem, TimeSpan?timeout = null, bool isSliding = false, CacheItemPriority priority = CacheItemPriority.Normal, CacheItemRemovedCallback removedCallback = null, string[] dependentFiles = null) { InnerProvider.InsertCacheItem(cacheKey, () => { var result = DictionaryCacheProviderBase.GetSafeLazy(getCacheItem); var value = result.Value; // force evaluation now - this may throw if cacheItem throws, and then nothing goes into cache if (value == null) { return(null); // do not store null values (backward compat) } return(CheckCloneableAndTracksChanges(value)); }, timeout, isSliding, priority, removedCallback, dependentFiles); }
public object GetCacheItem(string cacheKey, Func <object> getCacheItem) { var cached = InnerProvider.GetCacheItem(cacheKey, () => { var result = DictionaryCacheProviderBase.GetSafeLazy(getCacheItem); var value = result.Value; // force evaluation now - this may throw if cacheItem throws, and then nothing goes into cache if (value == null) { return(null); // do not store null values (backward compat) } return(CheckCloneableAndTracksChanges(value)); }); return(CheckCloneableAndTracksChanges(cached)); }