/// <summary> /// Using IMemoryCache as a cache service. /// </summary> public EFEasyCachingCoreProvider( IOptions <EFCoreSecondLevelCacheSettings> cacheSettings, IServiceProvider serviceProvider, IReaderWriterLockProvider readerWriterLockProvider) { if (cacheSettings == null) { throw new ArgumentNullException(nameof(cacheSettings)); } if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } _cacheSettings = cacheSettings.Value; _readerWriterLockProvider = readerWriterLockProvider ?? throw new ArgumentNullException(nameof(readerWriterLockProvider)); if (_cacheSettings.IsHybridCache) { var hybridFactory = serviceProvider.GetRequiredService <IHybridProviderFactory>(); _easyCachingProvider = hybridFactory.GetHybridCachingProvider(_cacheSettings.ProviderName); } else { var providerFactory = serviceProvider.GetRequiredService <IEasyCachingProviderFactory>(); _easyCachingProvider = providerFactory.GetCachingProvider(_cacheSettings.ProviderName); } }
/// <summary> /// Using IMemoryCache as a cache service. /// </summary> public EFEasyCachingCoreProvider( IOptions <EFCoreSecondLevelCacheSettings> cacheSettings, IServiceProvider serviceProvider, IReaderWriterLockProvider readerWriterLockProvider) { _cacheSettings = cacheSettings?.Value; _readerWriterLockProvider = readerWriterLockProvider; if (_cacheSettings.IsHybridCache) { var hybridFactory = serviceProvider.GetRequiredService <IHybridProviderFactory>(); _easyCachingProvider = hybridFactory.GetHybridCachingProvider(_cacheSettings.ProviderName); } else { var providerFactory = serviceProvider.GetRequiredService <IEasyCachingProviderFactory>(); _easyCachingProvider = providerFactory.GetCachingProvider(_cacheSettings.ProviderName); } }
public static IReturnValueArgumentValidationConfiguration <Task <Object> > CallToGetAsync <T>(this IEasyCachingProviderBase cachingProvider) => A.CallTo(() => cachingProvider.GetAsync(A <string> ._, typeof(T)));
public static IReturnValueArgumentValidationConfiguration <Task <CacheValue <T> > > CallToGetAsyncTyped <T>(this IEasyCachingProviderBase cachingProvider) => A.CallTo(() => cachingProvider.GetAsync <T>(A <string> ._));
public static IReturnValueArgumentValidationConfiguration <Task <CacheValue <T> > > CallToGetAsyncWithDataRetriever <T>(this IEasyCachingProviderBase cachingProvider) => A.CallTo(() => cachingProvider.GetAsync <T>(A <string> ._, A <Func <Task <T> > > ._, A <TimeSpan> ._));