Skip to content
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
2 changes: 1 addition & 1 deletion CacheManager.Redis/CacheSource/RedisCacheSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
var server = connectionMultiplexer.GetServer(_config.ConnectionString);
var pattern = $"{_keyPrefix}*";

await foreach (var key in server.KeysAsync(pattern: pattern))
await foreach (var key in server.KeysAsync(pattern: pattern).ConfigureAwait(false))
{
_ = await _redisCache.KeyDeleteAsync(key).ConfigureAwait(false);
}
Expand Down Expand Up @@ -118,7 +118,7 @@
/// Dispose
/// </summary>
/// <returns></returns>
public async ValueTask DisposeAsync() => await StopAsync().ConfigureAwait(false);

Check warning on line 121 in CacheManager.Redis/CacheSource/RedisCacheSource.cs

View workflow job for this annotation

GitHub Actions / build

Change RedisCacheSource.DisposeAsync() to call GC.SuppressFinalize(object). This will prevent derived types that introduce a finalizer from needing to re-implement 'IDisposable' to call it. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1816)

/// <summary>
/// Priority, Lowest priority - checked last
Expand Down
6 changes: 3 additions & 3 deletions CacheManager/CacheManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<RepositoryType>public</RepositoryType>
<PackageTags>CacheManager</PackageTags>
<PackageReleaseNotes>CacheManager</PackageReleaseNotes>
<AssemblyVersion>2.1.0</AssemblyVersion>
<FileVersion>2.1.0</FileVersion>
<Version>2.1.0</Version>
<AssemblyVersion>2.1.1</AssemblyVersion>
<FileVersion>2.1.1</FileVersion>
<Version>2.1.1</Version>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>MHKarami97.snk</AssemblyOriginatorKeyFile>
<PublicSign>true</PublicSign>
Expand Down
3 changes: 2 additions & 1 deletion CacheManager/CacheSource/ICacheSourceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface ICacheSourceBase : IAsyncDisposable
/// Stop cache source
/// </summary>
/// <returns></returns>
Task StopAsync();
public Task StopAsync();

/// <summary>
/// Priority, Lowest priority - checked last
Expand All @@ -20,6 +20,7 @@ public interface ICacheSourceBase : IAsyncDisposable
/// The value of <see cref="Priority"/> should be between 1 and 100.
/// </remarks>
[Range(1, 100)]
public
#if NET8_0_OR_GREATER
int Priority { get; init; }
#else
Expand Down
2 changes: 1 addition & 1 deletion CacheManager/CacheSource/ICacheSourceWithGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public interface ICacheSourceWithGet : ICacheSourceBase
/// </summary>
/// <param name="key">Key</param>
/// <returns>Result</returns>
Task<T?> GetAsync<T>(string key);
public Task<T?> GetAsync<T>(string key);
}
4 changes: 2 additions & 2 deletions CacheManager/CacheSource/ICacheSourceWithGetWithClear.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public interface ICacheSourceWithGetWithClear : ICacheSourceWithGet
/// Clear from cache with key
/// </summary>
/// <param name="key"></param>
Task ClearAsync(string key);
public Task ClearAsync(string key);

/// <summary>
/// Clear all from cache
/// </summary>
Task ClearAllAsync();
public Task ClearAllAsync();
}
2 changes: 1 addition & 1 deletion CacheManager/CacheSource/ICacheSourceWithGetWithSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public interface ICacheSourceWithGetWithSet : ICacheSourceWithGet
/// </summary>
/// <param name="key">Key</param>
/// <param name="data">Data to cache</param>
Task SetAsync<T>(string key, T data);
public Task SetAsync<T>(string key, T data);
}
9 changes: 0 additions & 9 deletions CacheManager/Config/LockConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
/// </summary>
public class LockConfig
{
/// <summary>
/// The maximum number of requests for the semaphore that can be granted concurrently. Defaults to 1.
/// </summary>
#if NET8_0_OR_GREATER
public int MaxCount { get; init; } = 1;
#else
public int MaxCount { get; set; } = 1;
#endif

/// <summary>
/// The size of the pool to use in order for generated objects to be reused. This is NOT a concurrency limit,
/// but if the pool is empty then a new object will be created rather than waiting for an object to return to
Expand Down
4 changes: 3 additions & 1 deletion CacheManager/EasyCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

if (duplicatePriorities.Count != 0)
{
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Duplicate_priority, string.Join(", ", duplicatePriorities)), nameof(cacheSources));

Check warning on line 52 in CacheManager/EasyCacheManager.cs

View workflow job for this annotation

GitHub Actions / build

Cache a 'CompositeFormat' for repeated use in this formatting operation (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1863)
}

_cacheSources = baseCacheSources.OrderBy(x => x.Priority);
Expand All @@ -58,7 +58,9 @@

_asyncLock = new AsyncKeyedLocker<string>(new AsyncKeyedLockOptions
{
PoolSize = Environment.ProcessorCount * lockConfig.PoolSize, PoolInitialFill = lockConfig.PoolInitialFill, MaxCount = lockConfig.MaxCount
PoolSize = Environment.ProcessorCount * lockConfig.PoolSize,
PoolInitialFill = lockConfig.PoolInitialFill,
MaxCount = 1
});

_ongoingOperations = new ConcurrentDictionary<string, Task>();
Expand Down
10 changes: 5 additions & 5 deletions CacheManager/IEasyCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ public interface IEasyCacheManager : IAsyncDisposable
/// </summary>
/// <param name="key">Key</param>
/// <returns>cached item</returns>
Task<T?> GetAsync<T>(string key);
public Task<T?> GetAsync<T>(string key);

/// <summary>
/// Manual set value to cache
/// </summary>
/// <param name="key">Key</param>
/// <param name="value">Value</param>
/// <returns>cached item</returns>
Task SetAsync<T>(string key, T value);
public Task SetAsync<T>(string key, T value);

/// <summary>
/// Clear cached item by key
/// </summary>
/// <param name="key">Key</param>
Task ClearCacheAsync(string key);
public Task ClearCacheAsync(string key);

/// <summary>
/// Clear cached item from all
/// </summary>
Task ClearAllCacheAsync();
public Task ClearAllCacheAsync();

/// <summary>
/// Stop all cache sources
/// </summary>
/// <returns></returns>
Task StopAsync();
public Task StopAsync();
}
6 changes: 3 additions & 3 deletions CacheManagerClear/ICachePublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ public interface ICachePublisher : IAsyncDisposable
/// <param name="key">key</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <returns></returns>
Task PublishClearCacheAsync(string key, CancellationToken? cancellationToken);
public Task PublishClearCacheAsync(string key, CancellationToken? cancellationToken);

/// <summary>
/// Publish clear all cached event
/// </summary>
/// <returns></returns>
Task PublishClearAllCacheAsync(CancellationToken? cancellationToken);
public Task PublishClearAllCacheAsync(CancellationToken? cancellationToken);

/// <summary>
/// Stops the Kafka subscription process
/// </summary>
/// <returns></returns>
Task StopAsync();
public Task StopAsync();
}
4 changes: 2 additions & 2 deletions CacheManagerClear/ICacheSubscriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public interface ICacheSubscriber : IAsyncDisposable
/// <summary>
/// Subscriber for cache clear event
/// </summary>
Task SubscribeAsync(CancellationToken cancellationToken);
public Task SubscribeAsync(CancellationToken cancellationToken);

/// <summary>
/// Stops the subscription process
/// </summary>
/// <returns></returns>
Task StopAsync();
public Task StopAsync();
}
2 changes: 1 addition & 1 deletion CacheManagerUnitTest/EasyCacheManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class EasyCacheManagerTests : IAsyncLifetime

public Task InitializeAsync()
{
_lockConfig = new LockConfig { PoolSize = 1, PoolInitialFill = 1, MaxCount = 1, TimeOut = TimeSpan.FromSeconds(5) };
_lockConfig = new LockConfig { PoolSize = 1, PoolInitialFill = 1, TimeOut = TimeSpan.FromSeconds(5) };

return Task.CompletedTask;
}
Expand Down
Loading