Browse Source

Merge AbpCacheOptions and AbpDistributedCacheOptions. Resolved #1901

pull/1940/head
Halil İbrahim Kalkan 7 years ago
parent
commit
705407ba9f
  1. 32
      framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCacheOptions.cs
  2. 2
      framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs
  3. 29
      framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpDistributedCacheOptions.cs
  4. 4
      framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs
  5. 2
      framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/AbpCachingTestModule.cs

32
framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCacheOptions.cs

@ -1,32 +0,0 @@
using Microsoft.Extensions.Caching.Distributed;
using System;
using System.Collections.Generic;
namespace Volo.Abp.Caching
{
public class AbpCacheOptions
{
/// <summary>
/// Cache key prefix.
/// </summary>
public string KeyPrefix { get; set; }
/// <summary>
/// Global Cache entry options.
/// </summary>
public DistributedCacheEntryOptions GlobalCacheEntryOptions { get; set; }
/// <summary>
/// List of all cache configurators.
/// (func argument:Name of cache)
/// </summary>
public List<Func<string, DistributedCacheEntryOptions>> CacheConfigurators { get; set; } //TODO list item use a configurator interface instead?
public AbpCacheOptions()
{
CacheConfigurators = new List<Func<string, DistributedCacheEntryOptions>>();
GlobalCacheEntryOptions = new DistributedCacheEntryOptions();
KeyPrefix = "";
}
}
}

2
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<AbpCacheOptions>(cacheOptions =>
context.Services.Configure<AbpDistributedCacheOptions>(cacheOptions =>
{
cacheOptions.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromMinutes(20);
});

29
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.
/// </summary>
public bool HideErrors { get; set; } = true;
/// <summary>
/// Cache key prefix.
/// </summary>
public string KeyPrefix { get; set; }
/// <summary>
/// Global Cache entry options.
/// </summary>
public DistributedCacheEntryOptions GlobalCacheEntryOptions { get; set; }
/// <summary>
/// List of all cache configurators.
/// (func argument:Name of cache)
/// </summary>
public List<Func<string, DistributedCacheEntryOptions>> CacheConfigurators { get; set; } //TODO: use a configurator interface instead?
public AbpDistributedCacheOptions()
{
CacheConfigurators = new List<Func<string, DistributedCacheEntryOptions>>();
GlobalCacheEntryOptions = new DistributedCacheEntryOptions();
KeyPrefix = "";
}
}
}

4
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<AbpCacheOptions> cacheOption,
IOptions<AbpDistributedCacheOptions> cacheOption,
IOptions<AbpDistributedCacheOptions> distributedCacheOption,
IDistributedCache cache,
ICancellationTokenProvider cancellationTokenProvider,

2
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<AbpCacheOptions>(option =>
Configure<AbpDistributedCacheOptions>(option =>
{
option.CacheConfigurators.Add(cacheName =>
{

Loading…
Cancel
Save