EricksonLopez.Caching
dotnet-caching · Rendimiento y Caché
En esta página (20 secciones)
1. Identidad, Nivel y Perfil de Madurez#
2. Propuesta de Valor y Problema que Resuelve#
Enterprise multi-tier caching engine for .NET (In-Memory L1 + Redis L2). Features dual-scope stampede protection, atomic tag invalidation, multi-tenancy isolation, and Native AOT compliance.
IMemoryCache e IDistributedCache carecen de protección anti-estampida, propagan excepciones de Redis hacia handlers de negocio y arriesgan borrados masivos por prefijo vacío.
3. Instalación Rápida#
Paquete principal: EricksonLopez.Caching
dotnet add package EricksonLopez.Caching --version 1.0.0<PackageReference Include="EricksonLopez.Caching" Version="1.0.0" /><PackageVersion Include="EricksonLopez.Caching" Version="1.0.0" />4. Métricas Verificadas del Ecosistema#
Instantánea recuperada UTC: 2026-12-01
5. Cuándo Usar y Cuándo NO Usar#
Cuándo usar
- Quieres HybridCacheProvider L1 Memoria + L2 Redis con bloqueo anti-estampida, invalidación por etiquetas y manejo de errores vía Result<T>.
Cuándo NO usar
- Solo necesitas un diccionario en memoria sin TTL, invalidación por etiquetas ni coordinación distribuida en Redis.
6. Capacidades Principales e Invariantes de Diseño#
Protección Anti-Estampida Dual
Ejecución single-flight con SemaphoreSlim local por clave y leases atómicos Redis SETNX entre instancias.
Invalidación por Etiquetas y Particionado
Invalidación atómica por etiquetas mediante scripts Lua en Redis y aislamiento por tenant con AddTenantPartitionedCache.
7. Paquetes NuGet y Adaptadores Incluidos#
| ID del Paquete | Estado | NuGet / Local | TFMs | Estado AOT | Descargas | Descripción |
|---|---|---|---|---|---|---|
| EricksonLopez.CachingPrincipal | Publicado | v1.0.0 / v2.0.0 | net8.0, net9.0, net10.0 | AOT: Completo | 597 | High-performance in-memory and hybrid multi-tier caching engine for .NET. Features stampede protection via keyed synchronization, absolute/sliding TTLs, prefix eviction, and Native AOT compatibility. |
| EricksonLopez.Caching.Redis | Publicado | v1.0.0 / v2.0.0 | net8.0, net9.0, net10.0 | AOT: Completo | 136 | Redis L2 cache provider for EricksonLopez.Caching. Uses StackExchange.Redis for distributed caching with stampede protection via Lua scripts and prefix-based eviction. Native AOT-compatible compatible. |
8. Ejemplo Quick Start#
Basado en APIs públicas verificadas de EricksonLopez.Caching. Compila con `<ImplicitUsings>disable</ImplicitUsings>` e importaciones explícitas.
using System;
using System.Threading.Tasks;
using EricksonLopez.Caching;
using EricksonLopez.Result;
using var cache = new MemoryCacheProvider();
Result<string> item = await cache.GetOrCreateAsync(
key: "products:sku:48291",
factory: static _ => Task.FromResult("Widget Pro"),
options: CacheEntryOptions.FromAbsolute(TimeSpan.FromMinutes(10)));9. Arquitectura y Flujo de Dependencias#
Renderizando diagrama…
flowchart LR lib_caching["EricksonLopez.Caching (L2)"] lib_result["EricksonLopez.Result (L0)"] lib_caching --> lib_result lib_mediator["EricksonLopez.Mediator (L2)"] lib_mediator -.-> lib_caching
Ver descripción textual y tabla accesible
1 dependencias hacia librerías aguas arriba y 1 librerías dependientes aguas abajo verificadas en dependencies.json.
| Dirección | Librería | Nivel | Tipos de Relación |
|---|---|---|---|
| Aguas arriba | EricksonLopez.Result | L0 | Adaptador, Tiempo de compilación, Paquete NuGet |
| Aguas abajo | EricksonLopez.Mediator | L2 | Adaptador |
flowchart LR
lib_caching["EricksonLopez.Caching (L2)"]
lib_result["EricksonLopez.Result (L0)"]
lib_caching --> lib_result
lib_mediator["EricksonLopez.Mediator (L2)"]
lib_mediator -.-> lib_caching10. Target Frameworks y Matriz Native AOT / Trimming#
Inspección MSBuild `.csproj` sobre 2 paquetes: 2 Full, 0 Partial, 0 Incompatible, 0 NotApplicable (analizadores/generadores).
| ID del Paquete | IsAotCompatible | EnableTrimAnalyzer | Estado AOT Verificado | Target Frameworks |
|---|---|---|---|---|
| EricksonLopez.Caching | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Caching.Redis | true | true | Full | net8.0, net9.0, net10.0 |
11. Dependencias Aguas Arriba y Dependientes Aguas Abajo#
Dependencias Aguas Arriba (1)
Dependientes Aguas Abajo (1)
12. Adaptadores Opcionales e Integraciones Externas#
Aristas de Adaptadores Internos y Paquetes de Integración
- EricksonLopez.Caching→ EricksonLopez.Result (EricksonLopez.Result)
- EricksonLopez.Mediator.Caching (EricksonLopez.Mediator)→ EricksonLopez.Caching
Dependencias NuGet Externas Verificadas (4)
13. Resumen de Configuración y Registro en DI#
Puntos de Entrada DI y Configuración Verificados
CachingServiceCollectionExtensions.AddCacheInvalidatorRegisters the canonical `CacheInvalidator` as the default scoped `ICacheInvalidator`.
CachingServiceCollectionExtensions.AddCacheInvalidator<TInvalidator>Registers a custom implementation of `ICacheInvalidator` in the service collection.
CachingServiceCollectionExtensions.AddHybridCacheRegisters a `HybridCacheProvider` that coordinates an L1 local cache with an L2 distributed cache.
CachingServiceCollectionExtensions.AddMemoryCacheProviderRegisters the `MemoryCacheProvider` as the default singleton `ICacheProvider` and `ITaggedCacheProvider`.
CachingServiceCollectionExtensions.AddTenantPartitionedCacheDecorates an existing `ICacheProvider` registration with `TenantPartitionedCacheProvider` using the specified tenant resolution delegate.
CachingRedisServiceCollectionExtensions.AddRedisCachingAdds the Redis-backed L2 cache provider as the `ICacheProvider` and `ITaggedCacheProvider` implementation.
Tipos Públicos y Contratos Clave
EricksonLopez.Caching.CacheDiagnostics (class)Provides OpenTelemetry-compatible metrics and distributed tracing instruments for the caching library. Uses `Metrics.Meter` and `Diagnostics.ActivitySource` without external third-party dependencies.
EricksonLopez.Caching.CacheEntryOptions (class)Specifies expiration, eviction, and resilience rules for cached entries.
EricksonLopez.Caching.CacheInvalidator (class)Canonical implementation of `ICacheInvalidator` backed by `ICacheProvider`.
EricksonLopez.Caching.CachingServiceCollectionExtensions (class)Extension methods for configuring caching providers and services in Microsoft Dependency Injection.
EricksonLopez.Caching.HybridCacheEntryOptions (class)Specifies tiered expiration and eviction rules for hybrid (L1 in-memory + L2 distributed) cache entries.
EricksonLopez.Caching.HybridCacheProvider (class)Multi-tier hybrid cache coordinating an in-memory L1 cache with a distributed L2 cache. Provides tiered TTL configuration, graceful degradation upon L2 failure, and tag-based invalidation.
EricksonLopez.Caching.ICacheInvalidator (interface)Defines contracts for high-throughput cache invalidation by key prefix or hierarchical tag.
EricksonLopez.Caching.ICacheProvider (interface)Defines standard contract for caching operations with functional Result returns and stampede protection.
EricksonLopez.Caching.ICacheSerializer (interface)Defines an abstraction for serializing and deserializing cached objects for distributed cache stores.
EricksonLopez.Caching.ITaggedCacheProvider (interface)Defines a cache provider that supports categorizing entries with tags for multi-key bulk invalidation.
EricksonLopez.Caching.MemoryCacheOptions (class)Configuration options for the in-memory cache provider.
EricksonLopez.Caching.MemoryCacheProvider (class)High-throughput, thread-safe in-memory cache provider with stampede protection, tag-based eviction, fail-safe stale tolerance, LRU compaction, active background cleanup, and prefix invalidation.
14. Benchmarks de Rendimiento Verificados#
Todas las mediciones verificadas provienen estrictamente de `BenchmarkDotNet.Artifacts` ejecutados sobre .NET RyuJIT (existen 0 ejecuciones NativeAOT en esta instantánea).
No se verificaron archivos `BenchmarkDotNet.Artifacts` no-MEGA-AUDIT para esta librería en la instantánea (`hasBenchmarks: false`).
15. Historial de Versiones y Estado NuGet vs Repositorio#
Desfase de versiones detectado: la última versión publicada en NuGet.org es v1.0.0, mientras el HEAD del repositorio local está en v2.0.0.
| Versión | Origen | Fecha de Publicación | Resumen |
|---|---|---|---|
| v1.0.0 ↗ | github | 2026-09-22 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.Caching` | `1.0.0` | | `EricksonLopez.Caching.Redis` | `1.0.0` | --- For detailed changes, see [CHANGELOG.md](https://github.com/ericksonlopezf/dotnet-caching/blob/v1.0.0/CHANGELOG.md). |
| v1.0.0 ↗ | nuget | 2026-09-22 | Published EricksonLopez.Caching 1.0.0 to NuGet.org. |
16. Librerías Complementarias y Relacionadas#
Librerías en el mismo nivel, capa arquitectónica o vinculadas directamente mediante aristas de dependencia.
17. Documentación, API Reference y Enlaces del Portal#
Documentación Conceptual (Starlight) →
Referencia de API XML Extraída →
2 namespaces · 17 tipos · 148 miembros
Mapa de Dependencias del Ecosistema →
Centro de Aprendizaje y Manual →
Las páginas conceptuales por librería en Starlight se completan en M4; las páginas de API Reference en M3.2.
18. Repositorio Fuente, Licencia y Contribución#
Publicado bajo Licencia MIT. Todos los ensamblados cumplen los invariantes de compilación EricksonLopez.*: importaciones explícitas, firma fuerte (`EricksonLopez.snk`) y metadatos de autor en ASCII (`Erickson Lopez`).
19. Resolución de Problemas, Riesgos y Migración#
- Las claves, prefijos y etiquetas vacías lanzan ArgumentException de inmediato para evitar purgas accidentales de toda la caché.
- Desfase de versiones detectado: la última versión publicada en NuGet.org es v1.0.0, mientras el HEAD del repositorio local está en v2.0.0.
20. Evidencia de Calidad y Verificación#
- Firma Fuerte (`EricksonLopez.snk`)
- EricksonLopez.snk
- `ImplicitUsings=disable`
- disable
- Extracción de Documentación XML
- Verificado (2 namespaces, 17 tipos, 148 miembros)
- Atributos MSBuild AOT / Trimming
- 2 Full / 0 Partial / 0 Incompatible / 0 N/A
- Artefactos BenchmarkDotNet
- 0 total (0 measured, 0 na_error)
Límites Explícitos de Verificación y Alcance
- Todas las mediciones verificadas provienen estrictamente de `BenchmarkDotNet.Artifacts` ejecutados sobre .NET RyuJIT (existen 0 ejecuciones NativeAOT en esta instantánea).