Simplify.Cache.Proxy.Extensions 1.0.9

dotnet add package Simplify.Cache.Proxy.Extensions --version 1.0.9
                    
NuGet\Install-Package Simplify.Cache.Proxy.Extensions -Version 1.0.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Simplify.Cache.Proxy.Extensions" Version="1.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Simplify.Cache.Proxy.Extensions" Version="1.0.9" />
                    
Directory.Packages.props
<PackageReference Include="Simplify.Cache.Proxy.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Simplify.Cache.Proxy.Extensions --version 1.0.9
                    
#r "nuget: Simplify.Cache.Proxy.Extensions, 1.0.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Simplify.Cache.Proxy.Extensions@1.0.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Simplify.Cache.Proxy.Extensions&version=1.0.9
                    
Install as a Cake Addin
#tool nuget:?package=Simplify.Cache.Proxy.Extensions&version=1.0.9
                    
Install as a Cake Tool

Simplify.Cache.Proxy

<p align="center"> <img src="assets/redis-cache-proxy.svg" alt="Redis Cache Proxy logo" width="200" /> </p>

Biblioteca reutilizável que demonstra como encapsular repositórios atrás de um DispatchProxy com Redis. O repositório agora mantém apenas dois projetos:

  • src/Simplify.Cache.Proxy/ → pacote multi-target (namespace Simplify.Cache.Proxy) pronto para o NuGet.
  • tests/Simplify.Cache.Proxy.Tests/ → suíte de testes em xUnit (namespace Simplify.Cache.Proxy.Tests) que valida o comportamento público da extensão.

Simplify.Cache.Proxy

Principais recursos

  • [RedisCached] para definir TTL por repositório (mínimo de 30 min).
  • AddRedisCacheProxy registra IConnectionMultiplexer via connection string ou factory customizada.
  • AddRedisCachedRepository<TInterface, TImplementation>() decora a implementação concreta com um DispatchProxy que lê/escreve em Redis.
  • RedisCachingProxy serializa com System.Text.Json e gera chaves determinísticas para expressões LINQ (ExpressionExtensions + KeyExpressionVisitor).
  • Multi-target (netstandard2.0, net6.0, net7.0, net8.0) incluindo README e ícone no pacote.

Instalação (NuGet)

dotnet add package Simplify.Cache.Proxy.Extensions

Uso típico

services.AddRedisCacheProxy("localhost:6379");
services.AddRedisCachedRepository<ICustomerRepository, CustomerRepository>(
    defaultExpiration: TimeSpan.FromMinutes(30));

[RedisCached(expirationInMinutes: 5)]
internal sealed class CustomerRepository : ICustomerRepository
{
    // ...
}

Fluxo de desenvolvimento

Requisitos

Restaurar, compilar e testar

dotnet restore Simplify.Cache.Proxy.sln
dotnet build Simplify.Cache.Proxy.sln -c Release
dotnet test Simplify.Cache.Proxy.sln

Empacotar a extensão

dotnet pack src/Simplify.Cache.Proxy/Simplify.Cache.Proxy.csproj \
  -c Release -o ./artifacts

Estratégia de testes

Os testes vivem em tests/Simplify.Cache.Proxy.Tests (xUnit + FluentAssertions + NSubstitute) e cobrem:

  • Geração de chaves para expressões diferentes.
  • Cache miss/hit para métodos async/sync.
  • Aplicação correta das políticas de expiração (atributo vs. defaultExpiration).
  • Registro via IServiceCollection e injeção de IConnectionMultiplexer.

Execute dotnet test antes de qualquer PR e ao ajustar os cenários listados acima.

Publicação no NuGet

  • Workflow (.github/workflows/publish-extensions.yml) continua responsável por empacotar e publicar.
  • Dispare com tags extensions-v* (ex.: extensions-v1.0.7) ou manualmente via GitHub Actions.
  • Confirme dotnet pack localmente, atualize <VersionPrefix> e mantenha README/ícones sincronizados antes de publicar.

Contribuindo

  1. Fork/branch (git checkout -b feature/nome).
  2. Implemente a mudança, acrescente testes pertinentes.
  3. Rode dotnet build + dotnet test.
  4. Commit (git commit -am 'feat: descrição') e push.
  5. Abra o PR descrevendo impactos no pacote.

O objetivo é manter uma extensão enxuta, multi-target e bem testada para quem deseja reutilizar proxies de cache com Redis em seus próprios repositórios.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.9 157 11/15/2025

Initial release of the Simplify Cache Proxy extensions extracted from the sample project.