/// <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>
 /// EFCachePolicy Parser Utils
 /// </summary>
 public EFCachePolicyParser(
     IOptions <EFCoreSecondLevelCacheSettings> cacheSettings,
     IEFCacheDependenciesProcessor cacheDependenciesProcessor,
     IEFDebugLogger logger)
 {
     _cacheSettings = cacheSettings?.Value;
     _cacheDependenciesProcessor = cacheDependenciesProcessor;
     _logger = logger;
 }
Beispiel #3
0
 /// <summary>
 /// EFCachePolicy Parser Utils
 /// </summary>
 public EFCachePolicyParser(
     IOptions <EFCoreSecondLevelCacheSettings> cacheSettings,
     IEFSqlCommandsProcessor sqlCommandsProcessor,
     IEFDebugLogger logger)
 {
     _cacheSettings        = cacheSettings?.Value;
     _sqlCommandsProcessor = sqlCommandsProcessor;
     _logger = logger;
 }
Beispiel #4
0
 /// <summary>
 /// Using IMemoryCache as a cache service.
 /// </summary>
 public EFEasyCachingCoreProvider(
     IOptions <EFCoreSecondLevelCacheSettings> cacheSettings,
     IEasyCachingProviderFactory easyCachingProviderFactory,
     IReaderWriterLockProvider readerWriterLockProvider)
 {
     _cacheSettings              = cacheSettings?.Value;
     _readerWriterLockProvider   = readerWriterLockProvider;
     _easyCachingProviderFactory = easyCachingProviderFactory ?? throw new ArgumentNullException("Please register the `EasyCaching.Core`.");
     _easyCachingProvider        = _easyCachingProviderFactory.GetCachingProvider(_cacheSettings.ProviderName);
 }
        /// <summary>
        /// EFCachePolicy Parser Utils
        /// </summary>
        public EFCachePolicyParser(
            IOptions <EFCoreSecondLevelCacheSettings> cacheSettings,
            IEFSqlCommandsProcessor sqlCommandsProcessor,
            IEFDebugLogger logger)
        {
            if (cacheSettings == null)
            {
                throw new ArgumentNullException(nameof(cacheSettings));
            }

            _cacheSettings        = cacheSettings.Value;
            _sqlCommandsProcessor = sqlCommandsProcessor ?? throw new ArgumentNullException(nameof(sqlCommandsProcessor));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
        }
        /// <summary>
        /// Cache Dependencies Calculator
        /// </summary>
        public EFCacheDependenciesProcessor(
            IEFDebugLogger logger,
            IEFCacheServiceProvider cacheServiceProvider,
            IEFSqlCommandsProcessor sqlCommandsProcessor,
            IOptions <EFCoreSecondLevelCacheSettings> cacheSettings)
        {
            _logger = logger;
            _cacheServiceProvider = cacheServiceProvider;
            _sqlCommandsProcessor = sqlCommandsProcessor;

            if (cacheSettings == null)
            {
                throw new ArgumentNullException(nameof(cacheSettings));
            }

            _cacheSettings = cacheSettings.Value;
        }
        /// <summary>
        /// A custom cache key provider for EF queries.
        /// </summary>
        public EFCacheKeyProvider(
            IEFCacheDependenciesProcessor cacheDependenciesProcessor,
            IEFCachePolicyParser cachePolicyParser,
            IEFDebugLogger logger,
            IOptions <EFCoreSecondLevelCacheSettings> cacheSettings)
        {
            _cacheDependenciesProcessor = cacheDependenciesProcessor;
            _logger            = logger;
            _cachePolicyParser = cachePolicyParser;

            if (cacheSettings == null)
            {
                throw new ArgumentNullException(nameof(cacheSettings));
            }

            _cacheSettings = cacheSettings.Value;
        }
        /// <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);
            }
        }