Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release v1.9.1 #488

Merged
merged 8 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions build/releasenotes.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project>
<PropertyGroup>
<EasyCachingCorePackageNotes>
1. Support IServiceProvider in setupActions
</EasyCachingCorePackageNotes>
<EasyCachingMemcachedPackageNotes>
1. Upgrading dependencies.
</EasyCachingMemcachedPackageNotes>
<EasyCachingRedisPackageNotes>
1. Fixed redis distributed lock for different process.
2. Support code configuration for StackExchange.Redis.
1. Upgrading dependencies.
</EasyCachingRedisPackageNotes>
<EasyCachingSQLitePackageNotes>
1. Upgrading dependencies.
Expand Down Expand Up @@ -40,25 +40,22 @@
1. Upgrading dependencies.
</EasyCachingCSRedisPackageNotes>
<EasyCachingCSRedisBusPackageNotes>
1. Support async version of subscribe.
1. Upgrading dependencies.
</EasyCachingCSRedisBusPackageNotes>
<EasyCachingRedisBusPackageNotes>
1. Support code configuration for StackExchange.Redis.
2. Support async version of subscribe.
1. Upgrading dependencies.
</EasyCachingRedisBusPackageNotes>
<EasyCachingRabbitBusPackageNotes>
1. Support async version of subscribe.
1. Upgrading dependencies.
</EasyCachingRabbitBusPackageNotes>
<EasyCachingKafkaBusPackageNotes>
1. Support async version of subscribe.
1. Upgrading dependencies.
</EasyCachingKafkaBusPackageNotes>
<EasyCachingZookeeperBusPackageNotes>
1. Support async version of subscribe.
2. Rename WithConfluentKafkaBus to WithZookeeeperBus.
1. Upgrading dependencies.
</EasyCachingZookeeperBusPackageNotes>
<EasyCachingDiskPackageNotes>
1. Support custom serializer.
2. Fixed DiskCachingProvider async warning.
1. Upgrading dependencies.
</EasyCachingDiskPackageNotes>
<EasyCachingLiteDBPackageNotes>
1. Upgrading dependencies.
Expand Down
48 changes: 24 additions & 24 deletions build/version.props
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<Project>
<PropertyGroup>
<EasyCachingCorePackageVersion>1.9.0</EasyCachingCorePackageVersion>
<EasyCachingMemcachedPackageVersion>1.9.0</EasyCachingMemcachedPackageVersion>
<EasyCachingRedisPackageVersion>1.9.0</EasyCachingRedisPackageVersion>
<EasyCachingSQLitePackageVersion>1.9.0</EasyCachingSQLitePackageVersion>
<EasyCachingInMemoryPackageVersion>1.9.0</EasyCachingInMemoryPackageVersion>
<EasyCachingHybridPackageVersion>1.9.0</EasyCachingHybridPackageVersion>
<EasyCachingAspectCorePackageVersion>1.9.0</EasyCachingAspectCorePackageVersion>
<EasyCachingCastlePackageVersion>1.9.0</EasyCachingCastlePackageVersion>
<EasyCachingResponseCachingPackageVersion>1.9.0</EasyCachingResponseCachingPackageVersion>
<EasyCachingJsonPackageVersion>1.9.0</EasyCachingJsonPackageVersion>
<EasyCachingMessagePackPackageVersion>1.9.0</EasyCachingMessagePackPackageVersion>
<EasyCachingProtobufPackageVersion>1.9.0</EasyCachingProtobufPackageVersion>
<EasyCachingCSRedisPackageVersion>1.9.0</EasyCachingCSRedisPackageVersion>
<EasyCachingRedisBusPackageVersion>1.9.0</EasyCachingRedisBusPackageVersion>
<EasyCachingCSRedisBusPackageVersion>1.9.0</EasyCachingCSRedisBusPackageVersion>
<EasyCachingRabbitBusPackageVersion>1.9.0</EasyCachingRabbitBusPackageVersion>
<EasyCachingKafkaBusPackageVersion>1.9.0</EasyCachingKafkaBusPackageVersion>
<EasyCachingZookeeperBusPackageVersion>1.9.0</EasyCachingZookeeperBusPackageVersion>
<EasyCachingDiskPackageVersion>1.9.0</EasyCachingDiskPackageVersion>
<EasyCachingMsExtPackageVersion>1.9.0</EasyCachingMsExtPackageVersion>
<EasyCachingLiteDBPackageVersion>1.9.0</EasyCachingLiteDBPackageVersion>
<EasyCachingSTJsonPackageVersion>1.9.0</EasyCachingSTJsonPackageVersion>
<EasyCachingMemoryPackageVersion>1.9.0</EasyCachingMemoryPackageVersion>
<EasyCachingFaskKVPackageVersion>1.9.0</EasyCachingFaskKVPackageVersion>
<EasyCachingCorePackageVersion>1.9.1</EasyCachingCorePackageVersion>
<EasyCachingMemcachedPackageVersion>1.9.1</EasyCachingMemcachedPackageVersion>
<EasyCachingRedisPackageVersion>1.9.1</EasyCachingRedisPackageVersion>
<EasyCachingSQLitePackageVersion>1.9.1</EasyCachingSQLitePackageVersion>
<EasyCachingInMemoryPackageVersion>1.9.1</EasyCachingInMemoryPackageVersion>
<EasyCachingHybridPackageVersion>1.9.1</EasyCachingHybridPackageVersion>
<EasyCachingAspectCorePackageVersion>1.9.1</EasyCachingAspectCorePackageVersion>
<EasyCachingCastlePackageVersion>1.9.1</EasyCachingCastlePackageVersion>
<EasyCachingResponseCachingPackageVersion>1.9.1</EasyCachingResponseCachingPackageVersion>
<EasyCachingJsonPackageVersion>1.9.1</EasyCachingJsonPackageVersion>
<EasyCachingMessagePackPackageVersion>1.9.1</EasyCachingMessagePackPackageVersion>
<EasyCachingProtobufPackageVersion>1.9.1</EasyCachingProtobufPackageVersion>
<EasyCachingCSRedisPackageVersion>1.9.1</EasyCachingCSRedisPackageVersion>
<EasyCachingRedisBusPackageVersion>1.9.1</EasyCachingRedisBusPackageVersion>
<EasyCachingCSRedisBusPackageVersion>1.9.1</EasyCachingCSRedisBusPackageVersion>
<EasyCachingRabbitBusPackageVersion>1.9.1</EasyCachingRabbitBusPackageVersion>
<EasyCachingKafkaBusPackageVersion>1.9.1</EasyCachingKafkaBusPackageVersion>
<EasyCachingZookeeperBusPackageVersion>1.9.1</EasyCachingZookeeperBusPackageVersion>
<EasyCachingDiskPackageVersion>1.9.1</EasyCachingDiskPackageVersion>
<EasyCachingMsExtPackageVersion>1.9.1</EasyCachingMsExtPackageVersion>
<EasyCachingLiteDBPackageVersion>1.9.1</EasyCachingLiteDBPackageVersion>
<EasyCachingSTJsonPackageVersion>1.9.1</EasyCachingSTJsonPackageVersion>
<EasyCachingMemoryPackageVersion>1.9.1</EasyCachingMemoryPackageVersion>
<EasyCachingFaskKVPackageVersion>1.9.1</EasyCachingFaskKVPackageVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void configure(RedisBusOptions x)
x.Username = redisOptions.Username;
x.Password = redisOptions.Password;
x.SslHost = redisOptions.SslHost;
x.SerializerName = redisOptions.SerializerName;

foreach (var item in redisOptions.Endpoints) x.Endpoints.Add(item);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/In-Memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Startup
// below two settings are added in v0.8.0
// enable deep clone when reading object from cache or not, default value is true.
EnableReadDeepClone = true,
// enable deep clone when writing object to cache or not, default valuee is false.
// enable deep clone when writing object to cache or not, default value is false.
EnableWriteDeepClone = false,
};
// the max random second will be added to cache's expiration, default value is 120
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<ProjectReference Include="..\..\src\EasyCaching.Core\EasyCaching.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AspectCore.Core" Version="2.2.0" />
<PackageReference Include="AspectCore.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="AspectCore.Core" Version="2.3.0" />
<PackageReference Include="AspectCore.Extensions.DependencyInjection" Version="2.3.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
namespace Microsoft.Extensions.DependencyInjection
{
using EasyCaching.Core;
using EasyCaching.Core.Configurations;
using System;
using EasyCaching.Core.Configurations;
using System;

/// <summary>
/// EasyCaching service collection extensions.
/// </summary>
public static class EasyCachingServiceCollectionExtensions
{
/// <summary>
/// Adds the easycaching.
/// Adds the EasyCaching.
/// </summary>
/// <returns>The easy caching.</returns>
/// <param name="services">Services.</param>
Expand All @@ -30,5 +30,38 @@ public static IServiceCollection AddEasyCaching(this IServiceCollection services

return services;
}

/// <summary>
/// Adds the EasyCaching.
/// </summary>
/// <returns>The easy caching.</returns>
/// <param name="services">Services.</param>
/// <param name="setupAction">Setup action.</param>
public static IServiceCollection AddEasyCaching(this IServiceCollection services, Action<IServiceProvider, EasyCachingOptions> setupAction)
{
ArgumentCheck.NotNull(setupAction, nameof(setupAction));

// Options
services.AddSingleton(sp =>
{
var options = new EasyCachingOptions();
setupAction(sp, options);
return options;
});

// Extension services
services.AddSingleton(sp =>
{
var options = sp.GetRequiredService<EasyCachingOptions>();
foreach (var serviceExtension in options.Extensions)
{
serviceExtension.AddServices(services);
}

return options;
});

return services;
}
}
}
57 changes: 30 additions & 27 deletions src/EasyCaching.InMemory/DefaultInMemoryCachingProvider.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,12 @@ public override async Task<object> BaseGetAsync(string cacheKey, Type type, Canc
/// <returns>The async.</returns>
/// <param name="cacheKey">Cache key.</param>
/// <param name="cancellationToken">CancellationToken</param>
public override async Task BaseRemoveAsync(string cacheKey, CancellationToken cancellationToken = default)
public override Task BaseRemoveAsync(string cacheKey, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

await Task.Run(() => { _cache.Remove(cacheKey); }, cancellationToken);
_cache.Remove(cacheKey);
return Task.CompletedTask;
}

/// <summary>
Expand All @@ -175,7 +176,7 @@ public override async Task BaseRemoveAsync(string cacheKey, CancellationToken ca
/// <param name="expiration">Expiration.</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public override async Task BaseSetAsync<T>(string cacheKey, T cacheValue, TimeSpan expiration, CancellationToken cancellationToken = default)
public override Task BaseSetAsync<T>(string cacheKey, T cacheValue, TimeSpan expiration, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));
ArgumentCheck.NotNull(cacheValue, nameof(cacheValue), _options.CacheNulls);
Expand All @@ -187,12 +188,10 @@ public override async Task BaseSetAsync<T>(string cacheKey, T cacheValue, TimeSp
expiration = expiration.Add(TimeSpan.FromSeconds(addSec));
}

await Task.Run(() =>
{
//var valExpiration = expiration.Seconds <= 1 ? expiration : TimeSpan.FromSeconds(expiration.Seconds / 2);
//var val = new CacheValue<T>(cacheValue, true, valExpiration);
_cache.Set(cacheKey, cacheValue, expiration);
}, cancellationToken);
//var valExpiration = expiration.Seconds <= 1 ? expiration : TimeSpan.FromSeconds(expiration.Seconds / 2);
//var val = new CacheValue<T>(cacheValue, true, valExpiration);
_cache.Set(cacheKey, cacheValue, expiration);
return Task.CompletedTask;
}

/// <summary>
Expand All @@ -201,11 +200,11 @@ await Task.Run(() =>
/// <returns>The async.</returns>
/// <param name="cacheKey">Cache key.</param>
/// <param name="cancellationToken">CancellationToken</param>
public override async Task<bool> BaseExistsAsync(string cacheKey, CancellationToken cancellationToken = default)
public override Task<bool> BaseExistsAsync(string cacheKey, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

return await Task.FromResult(_cache.Exists(cacheKey));
return Task.FromResult(_cache.Exists(cacheKey));
}

/// <summary>
Expand All @@ -214,14 +213,15 @@ public override async Task<bool> BaseExistsAsync(string cacheKey, CancellationTo
/// <returns>The by prefix async.</returns>
/// <param name="prefix">Prefix.</param>
/// <param name="cancellationToken">CancellationToken</param>
public override async Task BaseRemoveByPrefixAsync(string prefix, CancellationToken cancellationToken = default)
public override Task BaseRemoveByPrefixAsync(string prefix, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(prefix, nameof(prefix));

var count = await Task.Run(() => _cache.RemoveByPrefix(prefix), cancellationToken);
var count = _cache.RemoveByPrefix(prefix);

if (_options.EnableLogging)
_logger?.LogInformation($"RemoveByPrefixAsync : prefix = {prefix} , count = {count}");
return Task.CompletedTask;
}

/// <summary>
Expand All @@ -230,17 +230,18 @@ public override async Task BaseRemoveByPrefixAsync(string prefix, CancellationTo
/// <returns>The by prefix async.</returns>
/// <param name="pattern">Pattern.</param>
/// <param name="cancellationToken">CancellationToken</param>
public override async Task BaseRemoveByPatternAsync(string pattern, CancellationToken cancellationToken = default)
public override Task BaseRemoveByPatternAsync(string pattern, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(pattern, nameof(pattern));

var searchPattern = this.ProcessSearchKeyPattern(pattern);
var searchKey = this.HandleSearchKeyPattern(pattern);
var count = await Task.Run(() => _cache.RemoveByPattern(searchKey, searchPattern), cancellationToken);

var count = _cache.RemoveByPattern(searchKey, searchPattern);

if (_options.EnableLogging)
_logger?.LogInformation($"BaseRemoveByPatternAsync : pattern = {pattern} , count = {count}");
return Task.CompletedTask;
}

/// <summary>
Expand All @@ -251,12 +252,13 @@ public override async Task BaseRemoveByPatternAsync(string pattern, Cancellation
/// <param name="expiration">Expiration.</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public override async Task BaseSetAllAsync<T>(IDictionary<string, T> values, TimeSpan expiration, CancellationToken cancellationToken = default)
public override Task BaseSetAllAsync<T>(IDictionary<string, T> values, TimeSpan expiration, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNegativeOrZero(expiration, nameof(expiration));
ArgumentCheck.NotNullAndCountGTZero(values, nameof(values));

await Task.Run(() => _cache.SetAll(values, expiration), cancellationToken);
_cache.SetAll(values, expiration);
return Task.CompletedTask;
}

/// <summary>
Expand All @@ -266,16 +268,16 @@ public override async Task BaseSetAllAsync<T>(IDictionary<string, T> values, Tim
/// <param name="cacheKeys">Cache keys.</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public override async Task<IDictionary<string, CacheValue<T>>> BaseGetAllAsync<T>(IEnumerable<string> cacheKeys, CancellationToken cancellationToken = default)
public override Task<IDictionary<string, CacheValue<T>>> BaseGetAllAsync<T>(IEnumerable<string> cacheKeys, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullAndCountGTZero(cacheKeys, nameof(cacheKeys));

if (_options.EnableLogging)
_logger?.LogInformation($"GetAllAsync : cacheKeys = {string.Join(",", cacheKeys)}");

return await Task.FromResult(_cache.GetAll<T>(cacheKeys));
return Task.FromResult(_cache.GetAll<T>(cacheKeys));
}


/// <summary>
/// Get all cacheKey by prefix async.
Expand All @@ -298,15 +300,15 @@ public override Task<IEnumerable<string>> BaseGetAllKeysByPrefixAsync(string pre
/// <param name="prefix">Prefix.</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public override async Task<IDictionary<string, CacheValue<T>>> BaseGetByPrefixAsync<T>(string prefix, CancellationToken cancellationToken = default)
public override Task<IDictionary<string, CacheValue<T>>> BaseGetByPrefixAsync<T>(string prefix, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(prefix, nameof(prefix));
var map = new Dictionary<string, CacheValue<T>>();

if (_options.EnableLogging)
_logger?.LogInformation($"GetByPrefixAsync : prefix = {prefix}");

return await Task.FromResult(_cache.GetByPrefix<T>(prefix));
return Task.FromResult(_cache.GetByPrefix<T>(prefix));
}

/// <summary>
Expand All @@ -315,28 +317,29 @@ public override async Task<IDictionary<string, CacheValue<T>>> BaseGetByPrefixAs
/// <returns>The all async.</returns>
/// <param name="cacheKeys">Cache keys.</param>
/// <param name="cancellationToken">CancellationToken</param>
public override async Task BaseRemoveAllAsync(IEnumerable<string> cacheKeys, CancellationToken cancellationToken = default)
public override Task BaseRemoveAllAsync(IEnumerable<string> cacheKeys, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullAndCountGTZero(cacheKeys, nameof(cacheKeys));

if (_options.EnableLogging)
_logger?.LogInformation($"RemoveAllAsync : cacheKeys = {string.Join(",", cacheKeys)}");

await Task.Run(() => _cache.RemoveAll(cacheKeys), cancellationToken);
_cache.RemoveAll(cacheKeys);
return Task.CompletedTask;
}

/// <summary>
/// Flush All Cached Item async.
/// </summary>
/// <returns>The async.</returns>
/// <param name="cancellationToken">CancellationToken</param>
public override async Task BaseFlushAsync(CancellationToken cancellationToken = default)
public override Task BaseFlushAsync(CancellationToken cancellationToken = default)
{
if (_options.EnableLogging)
_logger?.LogInformation("FlushAsync");

_cache.Clear();
await Task.CompletedTask;
return Task.CompletedTask;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/EasyCaching.LiteDB/EasyCaching.LiteDB.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<ProjectReference Include="..\EasyCaching.Core\EasyCaching.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LiteDB" Version="5.0.9" />
<PackageReference Include="LiteDB" Version="5.0.13" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
Expand Down
Loading
Loading