Aj.DCache 1.0.5

dotnet add package Aj.DCache --version 1.0.5
                    
NuGet\Install-Package Aj.DCache -Version 1.0.5
                    
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="Aj.DCache" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aj.DCache" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Aj.DCache" />
                    
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 Aj.DCache --version 1.0.5
                    
#r "nuget: Aj.DCache, 1.0.5"
                    
#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 Aj.DCache@1.0.5
                    
#: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=Aj.DCache&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Aj.DCache&version=1.0.5
                    
Install as a Cake Tool

Aj.DCache

🚀 Aj.DCache é uma biblioteca .NET para gerenciamento de cache distribuído, construída sobre DragonflyDB (compatível com Redis) e projetada para ser segura, escalável e fácil de integrar em ambientes de alta concorrência.


✨ Funcionalidades

  • Suporte completo ao protocolo Redis, DragonflyDB e KeyDB
  • Operações padrão de cache distribuído (get/set/remove)
  • Suporte ao padrão Lazy Caching (GetOrCreate)
  • Evita duplicidade com SETNX (gravação segura)
  • Integração simples com ILogger (compatível com Serilog)
  • Preparado para lock distribuído usando RedLock
  • Estrutura enxuta e amigável para múltiplos projetos .NET
  • 100% thread-safe
  • Preparado para uso em multi-tenancy

📦 Instalação

via NuGet:

dotnet add package Aj.DCache

🚀 Primeiros passos

Configure no Program.cs ou Startup.cs:

builder.Services.AddAjDCacheServices(configuration);

Exemplo de uso do cache:

var result = await DistributedCacheHelper.GetOrCreateAsync<MyObject>(
    key: "meu-cache",
    factory: async () => await ObterDoBanco(),
    expiration: TimeSpan.FromMinutes(5)
);

⚙️ Configuração do Redis / Dragonfly

No seu appsettings.json:

"AjDCacheOptions": {
  "Server": "localhost:6379,password=suasenha",
  "Environment": "Production",
  "ExpirationTimeout": 300,
  "LockTimeout": 3,
  "PollyRetryPolicy": 3,
  "UseCompression": true,
  "DataBaseId":
}

🛠️ Dependências


✅ Roadmap

  • Implementar lock distribuído (Redlock)
  • Suporte a cluster multi-node
  • Benchmarks comparativos
  • Documentação avançada
  • Melhorias no suporte a multi-tenancy

🤝 Contribuindo

Pull requests são muito bem-vindos! Abra uma issue ou envie sugestões para evoluirmos juntos.


📄 Licença

🎯 Baixe o arquivo pronto no link abaixo:

Download README.md


Estrutra do Projeto


Aj.DCache
│
├── Configuration
│     └── AjDCacheOptions.cs
│
├── Extensions
│     └── MemoryCacheExtensions.cs
│
├── Helpers
│     └── CompressionHelper.cs
│     └── DistributedLockHelper.cs
│
├── Interfaces
│     └── IAjMemoryCache.cs
│
├── Model
│     └── CacheEntry.cs
│
├── Providers
│     └── AjMemoryCache.cs
│     └── DistributedCacheProvider.cs
│
└── Services
      └── RedisCacheService.cs

Resumo

  • Interfaces → apenas contratos (IAjMemoryCache, ILockProvider, etc)

  • Providers → implementações concretas desses contratos

  • Services → serviços de alto nível que coordenam regras

  • Helpers → utilitários

  • Extensions → métodos de extensão

  • Model → DTOs/POCOs


Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
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.5 201 8/14/2025
1.0.4 137 8/11/2025
1.0.3 74 8/1/2025

Versão inicial do Aj.DCache com suporte a MemoryCache Local, Redis e DistributedCache Hibrido.