/// <summary> /// Adds a new item to the cache. /// </summary> /// <param name="cacheKey">key</param> /// <param name="value">value</param> /// <param name="cachePolicy">Defines the expiration mode of the cache item.</param> public void InsertValue(EFCacheKey cacheKey, EFCachedData value, EFCachePolicy cachePolicy) { _readerWriterLockProvider.TryWriteLocked(() => { if (value == null) { value = new EFCachedData { IsNull = true }; } var keyHash = cacheKey.KeyHash; foreach (var rootCacheKey in cacheKey.CacheDependencies) { var items = _easyCachingProvider.Get <HashSet <string> >(rootCacheKey); if (items.IsNull) { _easyCachingProvider.Set(rootCacheKey, new HashSet <string> { keyHash }, cachePolicy.CacheTimeout); } else { items.Value.Add(keyHash); _easyCachingProvider.Set(rootCacheKey, items.Value, cachePolicy.CacheTimeout); } } // We don't support Sliding Expiration at this time. -> https://github.com/dotnetcore/EasyCaching/issues/113 _easyCachingProvider.Set(keyHash, value, cachePolicy.CacheTimeout); }); }
public static IReturnValueArgumentValidationConfiguration <CacheValue <T> > CallToGetWithDataRetriever <T>(this IEasyCachingProviderBase cachingProvider) => A.CallTo(() => cachingProvider.Get(A <string> ._, A <Func <T> > ._, A <TimeSpan> ._));