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
6 changes: 5 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
[
"ms-dotnettools.csdevkit",
"ue.alphabetical-sorter"
]
],
"settings":
{
"remote.autoForwardPorts": false
}
}
},
"forwardPorts":
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
devcontainer:
image: mcr.microsoft.com/devcontainers/dotnet:8.0-bookworm
image: mcr.microsoft.com/devcontainers/dotnet:9.0-bookworm
volumes:
- ..:/workspace:cached
command: sleep infinity
Expand Down
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[*.{cs,vb}]

dotnet_diagnostic.severity = warning
dotnet_diagnostic.CS1591.severity = none
dotnet_diagnostic.IDE0001.severity = warning
dotnet_diagnostic.IDE0007.severity = warning
dotnet_diagnostic.IDE0008.severity = none
dotnet_diagnostic.IDE0010.severity = none
dotnet_diagnostic.IDE0028.severity = warning
dotnet_diagnostic.IDE0055.severity = none
dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.IDE0090.severity = warning
dotnet_diagnostic.IDE0160.severity = none
dotnet_diagnostic.IDE0161.severity = warning
dotnet_diagnostic.IDE0290.severity = warning
dotnet_diagnostic.IDE0300.severity = warning
dotnet_diagnostic.IDE0301.severity = warning
dotnet_diagnostic.IDE0303.severity = warning
dotnet_diagnostic.IDE0305.severity = warning

csharp_space_between_square_brackets = true
csharp_style_var_elsewhere = true:warning
csharp_style_var_for_built_in_types = true:warning
csharp_style_var_when_type_is_apparent = true:warning
dotnet_style_namespace_match_folder = false
dotnet_style_prefer_conditional_expression_over_return = false
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ jobs:
- name: Test
uses: devcontainers/ci@v0.3
with:
push: never
runCmd: dotnet test
push: never
runCmd: dotnet test
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
- name: Test
uses: devcontainers/ci@v0.3
with:
push: never
runCmd: dotnet test
push: never
runCmd: dotnet test
- name: Publish
uses: devcontainers/ci@v0.3
with:
push: never
runCmd: dotnet build -c Release && dotnet nuget push "**/*.nupkg" -k ${{ secrets.NUGET_KEY }} -n -s https://api.nuget.org/v3/index.json --skip-duplicate
push: never
runCmd: dotnet build -c Release && dotnet nuget push "**/*.nupkg" -k ${{ secrets.NUGET_KEY }} -n -s https://api.nuget.org/v3/index.json --skip-duplicate
2 changes: 0 additions & 2 deletions src/Configuration/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.Extensions.Caching.StackExchangeRedis;
using Microsoft.Extensions.Options;
using StackExchange.Redis;
using System.Diagnostics.CodeAnalysis;

namespace Microsoft.Extensions.DependencyInjection;

Expand All @@ -16,7 +15,6 @@ public static class ServiceCollectionExtensions
/// Adds L1L2RedisCache distributed caching services to the specified <c>IServiceCollection</c>.
/// </summary>
/// <returns>The <c>IServiceCollection</c> so that additional calls can be chained.</returns>
[SuppressMessage("Performance", "CA1849")]
public static IServiceCollection AddL1L2RedisCache(
this IServiceCollection services,
Action<L1L2RedisCacheOptions> setupAction)
Expand Down
15 changes: 6 additions & 9 deletions src/L1L2RedisCache.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using StackExchange.Redis;
using System.Diagnostics.CodeAnalysis;

namespace L1L2RedisCache;

Expand Down Expand Up @@ -35,7 +35,8 @@ public L1L2RedisCache(
L2Cache = l2CacheAccessor?.Invoke() ??
throw new ArgumentNullException(
nameof(l2CacheAccessor));
Logger = logger;
Logger = logger ??
NullLogger<L1L2RedisCache>.Instance;
MessagePublisher = messagePublisher ??
throw new ArgumentNullException(
nameof(messagePublisher));
Expand Down Expand Up @@ -87,7 +88,7 @@ public L1L2RedisCache(
/// <summary>
/// Optional. The logger.
/// </summary>
public ILogger<L1L2RedisCache>? Logger { get; }
public ILogger<L1L2RedisCache> Logger { get; }

/// <summary>
/// The pub/sub publisher.
Expand Down Expand Up @@ -121,7 +122,6 @@ public void Dispose()
/// </summary>
/// <param name="key">A string identifying the requested value.</param>
/// <returns>The located value or null.</returns>
[SuppressMessage("Reliability", "CA2000")]
public byte[]? Get(string key)
{
var value = L1Cache.Get(
Expand Down Expand Up @@ -245,7 +245,6 @@ await L2Cache
/// Removes the value with the given key.
/// </summary>
/// <param name="key">A string identifying the requested value.</param>
[SuppressMessage("Reliability", "CA2000")]
public void Remove(string key)
{
var semaphore = GetOrCreateLock(key, null);
Expand Down Expand Up @@ -313,7 +312,6 @@ await MessagePublisher
/// <param name="key">A string identifying the requested value.</param>
/// <param name="value">The value to set in the cache.</param>
/// <param name="options">The cache options for the value.</param>
[SuppressMessage("Reliability", "CA2000")]
public void Set(
string key,
byte[] value,
Expand Down Expand Up @@ -456,7 +454,6 @@ private SemaphoreSlim GetOrCreateLock(
}
}

[SuppressMessage("Reliability", "CA2000")]
private async Task<SemaphoreSlim> GetOrCreateLockAsync(
string key,
DistributedCacheEntryOptions? distributedCacheEntryOptions,
Expand Down Expand Up @@ -547,7 +544,7 @@ private async Task SubscribeAsync(
cancellationToken)
.ConfigureAwait(false))
{
Logger?.MessagingConfigurationInvalid(
Logger.MessagingConfigurationInvalid(
L1L2RedisCacheOptions.MessagingType);
}

Expand All @@ -560,7 +557,7 @@ await MessageSubscriber
}
catch (RedisConnectionException redisConnectionException)
{
Logger?.SubscriberFailed(
Logger.SubscriberFailed(
L1L2RedisCacheOptions
.SubscriberRetryDelay,
redisConnectionException);
Expand Down
10 changes: 5 additions & 5 deletions src/L1L2RedisCache.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AnalysisLevel>latest-all</AnalysisLevel>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -17,10 +17,10 @@
<None Include="../README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.*" />
<PackageReference Include="System.Text.Json" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="9.0.*" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.*" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.*" />
<PackageReference Include="System.Text.Json" Version="9.0.*" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="L1L2RedisCache.Tests.System" />
Expand Down
18 changes: 9 additions & 9 deletions tests/System/L1L2RedisCache.Tests.System.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AnalysisLevel>latest-all</AnalysisLevel>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None CopyToOutputDirectory="PreserveNewest" Include="appsettings.json" />
Expand All @@ -16,13 +16,13 @@
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.*" />
<PackageReference Include="coverlet.collector" Version="6.0.*" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.*" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.*" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.*" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.*" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.*" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions tests/Unit/L1L2RedisCache.Tests.Unit.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AnalysisLevel>latest-all</AnalysisLevel>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\L1L2RedisCache.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.*" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.*" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.*" />
<PackageReference Include="NSubstitute" Version="5.1.*" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.*" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.*" />
<PackageReference Include="NSubstitute" Version="5.3.*" />
</ItemGroup>
</Project>