From 705407ba9f56effeb1ccf0890791602a79cab4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 18 Oct 2019 12:47:42 +0300 Subject: [PATCH] Merge AbpCacheOptions and AbpDistributedCacheOptions. Resolved #1901 --- .../Volo/Abp/Caching/AbpCacheOptions.cs | 32 ------------------- .../Volo/Abp/Caching/AbpCachingModule.cs | 2 +- .../Abp/Caching/AbpDistributedCacheOptions.cs | 29 ++++++++++++++++- .../Volo/Abp/Caching/DistributedCache.cs | 4 +-- .../Volo/Abp/Caching/AbpCachingTestModule.cs | 2 +- 5 files changed, 32 insertions(+), 37 deletions(-) delete mode 100644 framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCacheOptions.cs diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCacheOptions.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCacheOptions.cs deleted file mode 100644 index 09e319c551..0000000000 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCacheOptions.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Extensions.Caching.Distributed; -using System; -using System.Collections.Generic; - -namespace Volo.Abp.Caching -{ - public class AbpCacheOptions - { - /// - /// Cache key prefix. - /// - public string KeyPrefix { get; set; } - - /// - /// Global Cache entry options. - /// - public DistributedCacheEntryOptions GlobalCacheEntryOptions { get; set; } - - /// - /// List of all cache configurators. - /// (func argument:Name of cache) - /// - public List> CacheConfigurators { get; set; } //TODO list item use a configurator interface instead? - - public AbpCacheOptions() - { - CacheConfigurators = new List>(); - GlobalCacheEntryOptions = new DistributedCacheEntryOptions(); - KeyPrefix = ""; - } - } -} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs index 04a29d5fb2..2a44b1a91e 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs @@ -22,7 +22,7 @@ namespace Volo.Abp.Caching context.Services.AddSingleton(typeof(IDistributedCache<>), typeof(DistributedCache<>)); - context.Services.Configure(cacheOptions => + context.Services.Configure(cacheOptions => { cacheOptions.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromMinutes(20); }); diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpDistributedCacheOptions.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpDistributedCacheOptions.cs index 7f79d0f001..1ba432c959 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpDistributedCacheOptions.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpDistributedCacheOptions.cs @@ -1,4 +1,8 @@ -namespace Volo.Abp.Caching +using System; +using System.Collections.Generic; +using Microsoft.Extensions.Caching.Distributed; + +namespace Volo.Abp.Caching { public class AbpDistributedCacheOptions { @@ -6,5 +10,28 @@ /// Throw or hide exceptions for the distributed cache. /// public bool HideErrors { get; set; } = true; + + /// + /// Cache key prefix. + /// + public string KeyPrefix { get; set; } + + /// + /// Global Cache entry options. + /// + public DistributedCacheEntryOptions GlobalCacheEntryOptions { get; set; } + + /// + /// List of all cache configurators. + /// (func argument:Name of cache) + /// + public List> CacheConfigurators { get; set; } //TODO: use a configurator interface instead? + + public AbpDistributedCacheOptions() + { + CacheConfigurators = new List>(); + GlobalCacheEntryOptions = new DistributedCacheEntryOptions(); + KeyPrefix = ""; + } } } diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs index 990d4e4ef7..1e24a08196 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs @@ -36,12 +36,12 @@ namespace Volo.Abp.Caching protected DistributedCacheEntryOptions DefaultCacheOptions; - private readonly AbpCacheOptions _cacheOption; + private readonly AbpDistributedCacheOptions _cacheOption; private readonly AbpDistributedCacheOptions _distributedCacheOption; public DistributedCache( - IOptions cacheOption, + IOptions cacheOption, IOptions distributedCacheOption, IDistributedCache cache, ICancellationTokenProvider cancellationTokenProvider, diff --git a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/AbpCachingTestModule.cs b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/AbpCachingTestModule.cs index 4202736b03..be003431f2 100644 --- a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/AbpCachingTestModule.cs +++ b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/AbpCachingTestModule.cs @@ -9,7 +9,7 @@ namespace Volo.Abp.Caching { public override void ConfigureServices(ServiceConfigurationContext context) { - Configure(option => + Configure(option => { option.CacheConfigurators.Add(cacheName => {