Skip to content

Commit

Permalink
Merge pull request #394 from dotnetcore/dev
Browse files Browse the repository at this point in the history
v1.6.1
  • Loading branch information
catcherwong authored Aug 20, 2022
2 parents 6b3f478 + c5ae208 commit 769ef24
Show file tree
Hide file tree
Showing 22 changed files with 646 additions and 449 deletions.
26 changes: 11 additions & 15 deletions build/releasenotes.props
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
<Project>
<PropertyGroup>
<EasyCachingCorePackageNotes>
1. IRedisCachingProvider Support SearchKeysAsync.
2. IRedisCachingProvider Support ZRangeByScore/ZRangeByScoreAsync.
1. Add CancellationToken for async methods.
</EasyCachingCorePackageNotes>
<EasyCachingMemcachedPackageNotes>
1. Upgrading dependencies.
2. Throw exception when can not connect to server
1. Add CancellationToken for async methods.
</EasyCachingMemcachedPackageNotes>
<EasyCachingRedisPackageNotes>
1. IRedisCachingProvider Support SearchKeysAsync/ZRangeByScore/ZRangeByScoreAsync.
2. Make clear exception message when serializer not match or notfound.
3. Upgrading dependencies.
1. Add CancellationToken for async methods.
2. Add persist key method to redis providers.
</EasyCachingRedisPackageNotes>
<EasyCachingSQLitePackageNotes>
1. Upgrading dependencies.
1. Add CancellationToken for async methods.
</EasyCachingSQLitePackageNotes>
<EasyCachingInMemoryPackageNotes>
1. Upgrading dependencies.
1. Add CancellationToken for async methods.
</EasyCachingInMemoryPackageNotes>
<EasyCachingHybridPackageNotes>
1. Upgrading dependencies.
1. Add CancellationToken for async methods.
</EasyCachingHybridPackageNotes>
<EasyCachingAspectCorePackageNotes>
1. Upgrading dependencies.
Expand All @@ -41,9 +38,8 @@
1. Upgrading dependencies.
</EasyCachingProtobufPackageNotes>
<EasyCachingCSRedisPackageNotes>
1. IRedisCachingProvider Support SearchKeysAsync/ZRangeByScore/ZRangeByScoreAsync.
2. Make clear exception message when serializer not match or notfound.
3. Upgrading dependencies.
1. Add CancellationToken for async methods.
2. Add persist key method to redis providers.
</EasyCachingCSRedisPackageNotes>
<EasyCachingCSRedisBusPackageNotes>
1. Upgrading dependencies.
Expand All @@ -55,10 +51,10 @@
1. Upgrading dependencies.
</EasyCachingRabbitBusPackageNotes>
<EasyCachingDiskPackageNotes>
1. Upgrading dependencies.
1. Add CancellationToken for async methods.
</EasyCachingDiskPackageNotes>
<EasyCachingLiteDBPackageNotes>
1. Upgrading dependencies.
1. Add CancellationToken for async methods.
</EasyCachingLiteDBPackageNotes>
<EasyCachingSTJsonPackageNotes>
1. Upgrading dependencies.
Expand Down
40 changes: 20 additions & 20 deletions build/version.props
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project>
<PropertyGroup>
<EasyCachingCorePackageVersion>1.6.0</EasyCachingCorePackageVersion>
<EasyCachingMemcachedPackageVersion>1.6.0</EasyCachingMemcachedPackageVersion>
<EasyCachingRedisPackageVersion>1.6.0</EasyCachingRedisPackageVersion>
<EasyCachingSQLitePackageVersion>1.6.0</EasyCachingSQLitePackageVersion>
<EasyCachingInMemoryPackageVersion>1.6.0</EasyCachingInMemoryPackageVersion>
<EasyCachingHybridPackageVersion>1.6.0</EasyCachingHybridPackageVersion>
<EasyCachingAspectCorePackageVersion>1.6.0</EasyCachingAspectCorePackageVersion>
<EasyCachingCastlePackageVersion>1.6.0</EasyCachingCastlePackageVersion>
<EasyCachingResponseCachingPackageVersion>1.6.0</EasyCachingResponseCachingPackageVersion>
<EasyCachingJsonPackageVersion>1.6.0</EasyCachingJsonPackageVersion>
<EasyCachingMessagePackPackageVersion>1.6.0</EasyCachingMessagePackPackageVersion>
<EasyCachingProtobufPackageVersion>1.6.0</EasyCachingProtobufPackageVersion>
<EasyCachingCSRedisPackageVersion>1.6.0</EasyCachingCSRedisPackageVersion>
<EasyCachingRedisBusPackageVersion>1.6.0</EasyCachingRedisBusPackageVersion>
<EasyCachingCSRedisBusPackageVersion>1.6.0</EasyCachingCSRedisBusPackageVersion>
<EasyCachingRabbitBusPackageVersion>1.6.0</EasyCachingRabbitBusPackageVersion>
<EasyCachingDiskPackageVersion>1.6.0</EasyCachingDiskPackageVersion>
<EasyCachingMsExtPackageVersion>1.6.0</EasyCachingMsExtPackageVersion>
<EasyCachingLiteDBPackageVersion>1.6.0</EasyCachingLiteDBPackageVersion>
<EasyCachingSTJsonPackageVersion>1.6.0</EasyCachingSTJsonPackageVersion>
<EasyCachingCorePackageVersion>1.6.1</EasyCachingCorePackageVersion>
<EasyCachingMemcachedPackageVersion>1.6.1</EasyCachingMemcachedPackageVersion>
<EasyCachingRedisPackageVersion>1.6.1</EasyCachingRedisPackageVersion>
<EasyCachingSQLitePackageVersion>1.6.1</EasyCachingSQLitePackageVersion>
<EasyCachingInMemoryPackageVersion>1.6.1</EasyCachingInMemoryPackageVersion>
<EasyCachingHybridPackageVersion>1.6.1</EasyCachingHybridPackageVersion>
<EasyCachingAspectCorePackageVersion>1.6.1</EasyCachingAspectCorePackageVersion>
<EasyCachingCastlePackageVersion>1.6.1</EasyCachingCastlePackageVersion>
<EasyCachingResponseCachingPackageVersion>1.6.1</EasyCachingResponseCachingPackageVersion>
<EasyCachingJsonPackageVersion>1.6.1</EasyCachingJsonPackageVersion>
<EasyCachingMessagePackPackageVersion>1.6.1</EasyCachingMessagePackPackageVersion>
<EasyCachingProtobufPackageVersion>1.6.1</EasyCachingProtobufPackageVersion>
<EasyCachingCSRedisPackageVersion>1.6.1</EasyCachingCSRedisPackageVersion>
<EasyCachingRedisBusPackageVersion>1.6.1</EasyCachingRedisBusPackageVersion>
<EasyCachingCSRedisBusPackageVersion>1.6.1</EasyCachingCSRedisBusPackageVersion>
<EasyCachingRabbitBusPackageVersion>1.6.1</EasyCachingRabbitBusPackageVersion>
<EasyCachingDiskPackageVersion>1.6.1</EasyCachingDiskPackageVersion>
<EasyCachingMsExtPackageVersion>1.6.1</EasyCachingMsExtPackageVersion>
<EasyCachingLiteDBPackageVersion>1.6.1</EasyCachingLiteDBPackageVersion>
<EasyCachingSTJsonPackageVersion>1.6.1</EasyCachingSTJsonPackageVersion>
</PropertyGroup>
</Project>
54 changes: 35 additions & 19 deletions src/EasyCaching.CSRedis/DefaultCSRedisCachingProvider.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using EasyCaching.Core;
using global::CSRedis;
Expand All @@ -14,32 +15,35 @@ public partial class DefaultCSRedisCachingProvider : EasyCachingAbstractProvider
/// </summary>
/// <returns>The async.</returns>
/// <param name="cacheKey">Cache key.</param>
public override async Task<bool> BaseExistsAsync(string cacheKey)
/// <param name="cancellationToken">CancellationToken</param>
public override async Task<bool> BaseExistsAsync(string cacheKey, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

return await _cache.ExistsAsync(cacheKey);
}

/// <summary>
/// Flushs the async.
/// </summary>
/// <param name="cancellationToken">CancellationToken</param>
/// <returns>The async.</returns>
public override async Task BaseFlushAsync()
public override async Task BaseFlushAsync(CancellationToken cancellationToken = default)
{
if (_options.EnableLogging)
_logger?.LogInformation("Redis -- FlushAsync");

await _cache.NodesServerManager.FlushDbAsync();
}

/// <summary>
/// Gets all async.
/// </summary>
/// <returns>The all async.</returns>
/// <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)
public override async Task<IDictionary<string, CacheValue<T>>> BaseGetAllAsync<T>(IEnumerable<string> cacheKeys, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullAndCountGTZero(cacheKeys, nameof(cacheKeys));

Expand Down Expand Up @@ -67,8 +71,9 @@ public override async Task<IDictionary<string, CacheValue<T>>> BaseGetAllAsync<T
/// <param name="cacheKey">Cache key.</param>
/// <param name="dataRetriever">Data retriever.</param>
/// <param name="expiration">Expiration.</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public override async Task<CacheValue<T>> BaseGetAsync<T>(string cacheKey, Func<Task<T>> dataRetriever, TimeSpan expiration)
public override async Task<CacheValue<T>> BaseGetAsync<T>(string cacheKey, Func<Task<T>> dataRetriever, TimeSpan expiration, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));
ArgumentCheck.NotNegativeOrZero(expiration, nameof(expiration));
Expand Down Expand Up @@ -120,7 +125,8 @@ public override async Task<CacheValue<T>> BaseGetAsync<T>(string cacheKey, Func<
/// <returns>The async.</returns>
/// <param name="cacheKey">Cache key.</param>
/// <param name="type">Object Type.</param>
public override async Task<object> BaseGetAsync(string cacheKey, Type type)
/// <param name="cancellationToken">CancellationToken</param>
public override async Task<object> BaseGetAsync(string cacheKey, Type type, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

Expand Down Expand Up @@ -151,8 +157,9 @@ public override async Task<object> BaseGetAsync(string cacheKey, Type type)
/// </summary>
/// <returns>The async.</returns>
/// <param name="cacheKey">Cache key.</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public override async Task<CacheValue<T>> BaseGetAsync<T>(string cacheKey)
public override async Task<CacheValue<T>> BaseGetAsync<T>(string cacheKey, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

Expand Down Expand Up @@ -183,7 +190,8 @@ public override async Task<CacheValue<T>> BaseGetAsync<T>(string cacheKey)
/// </summary>
/// <returns>The count.</returns>
/// <param name="prefix">Prefix.</param>
public override Task<int> BaseGetCountAsync(string prefix = "")
/// <param name="cancellationToken">CancellationToken</param>
public override Task<int> BaseGetCountAsync(string prefix = "", CancellationToken cancellationToken = default)
{
if (string.IsNullOrWhiteSpace(prefix))
{
Expand All @@ -207,8 +215,9 @@ public override Task<int> BaseGetCountAsync(string prefix = "")
/// </summary>
/// <returns>The by prefix async.</returns>
/// <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)
public override async Task<IDictionary<string, CacheValue<T>>> BaseGetByPrefixAsync<T>(string prefix, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(prefix, nameof(prefix));

Expand All @@ -229,13 +238,14 @@ public override async Task<IDictionary<string, CacheValue<T>>> BaseGetByPrefixAs

return result;
}

/// <summary>
/// Removes all async.
/// </summary>
/// <returns>The all async.</returns>
/// <param name="cacheKeys">Cache keys.</param>
public override async Task BaseRemoveAllAsync(IEnumerable<string> cacheKeys)
/// <param name="cancellationToken">CancellationToken</param>
public override async Task BaseRemoveAllAsync(IEnumerable<string> cacheKeys, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullAndCountGTZero(cacheKeys, nameof(cacheKeys));

Expand All @@ -254,19 +264,21 @@ public override async Task BaseRemoveAllAsync(IEnumerable<string> cacheKeys)
/// </summary>
/// <returns>The async.</returns>
/// <param name="cacheKey">Cache key.</param>
public override async Task BaseRemoveAsync(string cacheKey)
/// <param name="cancellationToken">CancellationToken</param>
public override async Task BaseRemoveAsync(string cacheKey, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

await _cache.DelAsync(cacheKey);
}
}

/// <summary>
/// Removes the by prefix async.
/// </summary>
/// <returns>The by prefix async.</returns>
/// <param name="prefix">Prefix.</param>
public override async Task BaseRemoveByPrefixAsync(string prefix)
/// <param name="cancellationToken">CancellationToken</param>
public override async Task BaseRemoveByPrefixAsync(string prefix, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(prefix, nameof(prefix));

Expand All @@ -293,8 +305,9 @@ public override async Task BaseRemoveByPrefixAsync(string prefix)
/// <returns>The all async.</returns>
/// <param name="value">Value.</param>
/// <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> value, TimeSpan expiration)
public override async Task BaseSetAllAsync<T>(IDictionary<string, T> value, TimeSpan expiration, CancellationToken cancellationToken = default)
{
//whether to use pipe based on redis mode
var tasks = new List<Task<bool>>();
Expand All @@ -320,8 +333,9 @@ public override async Task BaseSetAllAsync<T>(IDictionary<string, T> value, Time
/// <param name="cacheKey">Cache key.</param>
/// <param name="cacheValue">Cache value.</param>
/// <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)
public override async 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 Down Expand Up @@ -349,8 +363,9 @@ await _cache.SetAsync(
/// <param name="cacheKey">Cache key.</param>
/// <param name="cacheValue">Cache value.</param>
/// <param name="expiration">Expiration.</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public override async Task<bool> BaseTrySetAsync<T>(string cacheKey, T cacheValue, TimeSpan expiration)
public override async Task<bool> BaseTrySetAsync<T>(string cacheKey, T cacheValue, TimeSpan expiration, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));
ArgumentCheck.NotNull(cacheValue, nameof(cacheValue), _options.CacheNulls);
Expand All @@ -374,8 +389,9 @@ public override async Task<bool> BaseTrySetAsync<T>(string cacheKey, T cacheValu
/// Get the expiration of cache key async
/// </summary>
/// <param name="cacheKey">cache key</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <returns>expiration</returns>
public override async Task<TimeSpan> BaseGetExpirationAsync(string cacheKey)
public override async Task<TimeSpan> BaseGetExpirationAsync(string cacheKey, CancellationToken cancellationToken = default)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

Expand Down
66 changes: 41 additions & 25 deletions src/EasyCaching.CSRedis/DefaultCSRedisCachingProvider.Keys.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
namespace EasyCaching.CSRedis
namespace EasyCaching.CSRedis
{
using EasyCaching.Core;
using System.Collections.Generic;
using System.Threading.Tasks;

public partial class DefaultCSRedisCachingProvider : IRedisCachingProvider
{
public string RedisName => this._name;

using System.Threading.Tasks;

public partial class DefaultCSRedisCachingProvider : IRedisCachingProvider
{
public string RedisName => this._name;

public bool KeyDel(string cacheKey)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));
Expand Down Expand Up @@ -38,22 +38,38 @@ public async Task<bool> KeyExpireAsync(string cacheKey, int second)

var flag = await _cache.ExpireAsync(cacheKey, second);
return flag;
}

public bool KeyExists(string cacheKey)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

var flag = _cache.Exists(cacheKey);
return flag;
}

public async Task<bool> KeyExistsAsync(string cacheKey)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

var flag = await _cache.ExistsAsync(cacheKey);
return flag;
}

public bool KeyPersist(string cacheKey)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

var flag = _cache.Persist(cacheKey);
return flag;
}

public async Task<bool> KeyPersistAsync(string cacheKey)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

var flag = await _cache.PersistAsync(cacheKey);
return flag;
}

public bool KeyExists(string cacheKey)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

var flag = _cache.Exists(cacheKey);
return flag;
}

public async Task<bool> KeyExistsAsync(string cacheKey)
{
ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey));

var flag = await _cache.ExistsAsync(cacheKey);
return flag;
}

public long TTL(string cacheKey)
Expand Down Expand Up @@ -123,5 +139,5 @@ public async Task<List<string>> SearchKeysAsync(string cacheKey, int? count)

return keys;
}
}
}
}
}
Loading

0 comments on commit 769ef24

Please sign in to comment.