/// <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);
            }
        }
예제 #3
0
 public static IReturnValueArgumentValidationConfiguration <Task <Object> > CallToGetAsync <T>(this IEasyCachingProviderBase cachingProvider) =>
 A.CallTo(() => cachingProvider.GetAsync(A <string> ._, typeof(T)));
예제 #4
0
 public static IReturnValueArgumentValidationConfiguration <Task <CacheValue <T> > > CallToGetAsyncTyped <T>(this IEasyCachingProviderBase cachingProvider) =>
 A.CallTo(() => cachingProvider.GetAsync <T>(A <string> ._));
예제 #5
0
 public static IReturnValueArgumentValidationConfiguration <Task <CacheValue <T> > > CallToGetAsyncWithDataRetriever <T>(this IEasyCachingProviderBase cachingProvider) =>
 A.CallTo(() => cachingProvider.GetAsync <T>(A <string> ._, A <Func <Task <T> > > ._, A <TimeSpan> ._));