Skip to content

Commit 8ea2975

Browse files
authored
Merge pull request #6 from EasyNuget/users/mhkarami97/fix-async-lock
fix: remove MaxCount from async lock config
2 parents d55c55e + 3ea1ec7 commit 8ea2975

File tree

12 files changed

+24
-30
lines changed

12 files changed

+24
-30
lines changed

CacheManager.Redis/CacheSource/RedisCacheSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public async Task ClearAllAsync()
8787
var server = connectionMultiplexer.GetServer(_config.ConnectionString);
8888
var pattern = $"{_keyPrefix}*";
8989

90-
await foreach (var key in server.KeysAsync(pattern: pattern))
90+
await foreach (var key in server.KeysAsync(pattern: pattern).ConfigureAwait(false))
9191
{
9292
_ = await _redisCache.KeyDeleteAsync(key).ConfigureAwait(false);
9393
}

CacheManager/CacheManager.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
<RepositoryType>public</RepositoryType>
1919
<PackageTags>CacheManager</PackageTags>
2020
<PackageReleaseNotes>CacheManager</PackageReleaseNotes>
21-
<AssemblyVersion>2.1.0</AssemblyVersion>
22-
<FileVersion>2.1.0</FileVersion>
23-
<Version>2.1.0</Version>
21+
<AssemblyVersion>2.1.1</AssemblyVersion>
22+
<FileVersion>2.1.1</FileVersion>
23+
<Version>2.1.1</Version>
2424
<SignAssembly>true</SignAssembly>
2525
<AssemblyOriginatorKeyFile>MHKarami97.snk</AssemblyOriginatorKeyFile>
2626
<PublicSign>true</PublicSign>

CacheManager/CacheSource/ICacheSourceBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public interface ICacheSourceBase : IAsyncDisposable
1111
/// Stop cache source
1212
/// </summary>
1313
/// <returns></returns>
14-
Task StopAsync();
14+
public Task StopAsync();
1515

1616
/// <summary>
1717
/// Priority, Lowest priority - checked last
@@ -20,6 +20,7 @@ public interface ICacheSourceBase : IAsyncDisposable
2020
/// The value of <see cref="Priority"/> should be between 1 and 100.
2121
/// </remarks>
2222
[Range(1, 100)]
23+
public
2324
#if NET8_0_OR_GREATER
2425
int Priority { get; init; }
2526
#else

CacheManager/CacheSource/ICacheSourceWithGet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ public interface ICacheSourceWithGet : ICacheSourceBase
1010
/// </summary>
1111
/// <param name="key">Key</param>
1212
/// <returns>Result</returns>
13-
Task<T?> GetAsync<T>(string key);
13+
public Task<T?> GetAsync<T>(string key);
1414
}

CacheManager/CacheSource/ICacheSourceWithGetWithClear.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public interface ICacheSourceWithGetWithClear : ICacheSourceWithGet
99
/// Clear from cache with key
1010
/// </summary>
1111
/// <param name="key"></param>
12-
Task ClearAsync(string key);
12+
public Task ClearAsync(string key);
1313

1414
/// <summary>
1515
/// Clear all from cache
1616
/// </summary>
17-
Task ClearAllAsync();
17+
public Task ClearAllAsync();
1818
}

CacheManager/CacheSource/ICacheSourceWithGetWithSet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ public interface ICacheSourceWithGetWithSet : ICacheSourceWithGet
1010
/// </summary>
1111
/// <param name="key">Key</param>
1212
/// <param name="data">Data to cache</param>
13-
Task SetAsync<T>(string key, T data);
13+
public Task SetAsync<T>(string key, T data);
1414
}

CacheManager/Config/LockConfig.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@
55
/// </summary>
66
public class LockConfig
77
{
8-
/// <summary>
9-
/// The maximum number of requests for the semaphore that can be granted concurrently. Defaults to 1.
10-
/// </summary>
11-
#if NET8_0_OR_GREATER
12-
public int MaxCount { get; init; } = 1;
13-
#else
14-
public int MaxCount { get; set; } = 1;
15-
#endif
16-
178
/// <summary>
189
/// The size of the pool to use in order for generated objects to be reused. This is NOT a concurrency limit,
1910
/// but if the pool is empty then a new object will be created rather than waiting for an object to return to

CacheManager/EasyCacheManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ public EasyCacheManager([Required] IEnumerable<ICacheSourceWithGet> cacheSources
5858

5959
_asyncLock = new AsyncKeyedLocker<string>(new AsyncKeyedLockOptions
6060
{
61-
PoolSize = Environment.ProcessorCount * lockConfig.PoolSize, PoolInitialFill = lockConfig.PoolInitialFill, MaxCount = lockConfig.MaxCount
61+
PoolSize = Environment.ProcessorCount * lockConfig.PoolSize,
62+
PoolInitialFill = lockConfig.PoolInitialFill,
63+
MaxCount = 1
6264
});
6365

6466
_ongoingOperations = new ConcurrentDictionary<string, Task>();

CacheManager/IEasyCacheManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@ public interface IEasyCacheManager : IAsyncDisposable
1010
/// </summary>
1111
/// <param name="key">Key</param>
1212
/// <returns>cached item</returns>
13-
Task<T?> GetAsync<T>(string key);
13+
public Task<T?> GetAsync<T>(string key);
1414

1515
/// <summary>
1616
/// Manual set value to cache
1717
/// </summary>
1818
/// <param name="key">Key</param>
1919
/// <param name="value">Value</param>
2020
/// <returns>cached item</returns>
21-
Task SetAsync<T>(string key, T value);
21+
public Task SetAsync<T>(string key, T value);
2222

2323
/// <summary>
2424
/// Clear cached item by key
2525
/// </summary>
2626
/// <param name="key">Key</param>
27-
Task ClearCacheAsync(string key);
27+
public Task ClearCacheAsync(string key);
2828

2929
/// <summary>
3030
/// Clear cached item from all
3131
/// </summary>
32-
Task ClearAllCacheAsync();
32+
public Task ClearAllCacheAsync();
3333

3434
/// <summary>
3535
/// Stop all cache sources
3636
/// </summary>
3737
/// <returns></returns>
38-
Task StopAsync();
38+
public Task StopAsync();
3939
}

CacheManagerClear/ICachePublisher.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ public interface ICachePublisher : IAsyncDisposable
1111
/// <param name="key">key</param>
1212
/// <param name="cancellationToken">CancellationToken</param>
1313
/// <returns></returns>
14-
Task PublishClearCacheAsync(string key, CancellationToken? cancellationToken);
14+
public Task PublishClearCacheAsync(string key, CancellationToken? cancellationToken);
1515

1616
/// <summary>
1717
/// Publish clear all cached event
1818
/// </summary>
1919
/// <returns></returns>
20-
Task PublishClearAllCacheAsync(CancellationToken? cancellationToken);
20+
public Task PublishClearAllCacheAsync(CancellationToken? cancellationToken);
2121

2222
/// <summary>
2323
/// Stops the Kafka subscription process
2424
/// </summary>
2525
/// <returns></returns>
26-
Task StopAsync();
26+
public Task StopAsync();
2727
}

0 commit comments

Comments
 (0)