EricksonLopez.Caching

dotnet-caching · Rendimiento y Caché

En esta página (20 secciones)

1. Identidad, Nivel y Perfil de Madurez#

L2 Transversal y FiabilidadEstableMantenimiento: MantenidoAOT: CompletoLicencia MITConfianza: HIGH
ApplicationCross-Cuttingnet8.0net9.0net10.0

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
También publicado en esta familia:
EricksonLopez.Caching.Redis

4. Métricas Verificadas del Ecosistema#

v1.0.0
Versión Publicada en NuGet
v2.0.0
Versión HEAD del Repo
733
Descargas en NuGet
2
Paquetes Empaquetables
148
Miembros Públicos de API
0
Filas Benchmark (RyuJIT)

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 PaqueteEstadoNuGet / LocalTFMsEstado AOTDescargasDescripción
EricksonLopez.CachingPrincipalPublicadov1.0.0 / v2.0.0net8.0, net9.0, net10.0AOT: Completo597High-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.RedisPublicadov1.0.0 / v2.0.0net8.0, net9.0, net10.0AOT: Completo136Redis 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#

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
Topología de Dependencias de EricksonLopez.Caching1 dependencias hacia librerías aguas arriba y 1 librerías dependientes aguas abajo verificadas en dependencies.json.
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ónLibreríaNivelTipos de Relación
Aguas arribaEricksonLopez.ResultL0Adaptador, Tiempo de compilación, Paquete NuGet
Aguas abajoEricksonLopez.MediatorL2Adaptador
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

10. 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 PaqueteIsAotCompatibleEnableTrimAnalyzerEstado AOT VerificadoTarget Frameworks
EricksonLopez.CachingtruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.Caching.RedistruetrueFullnet8.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

Dependencias NuGet Externas Verificadas (4)

Microsoft.Extensions.DependencyInjection.AbstractionsMicrosoft.Extensions.Logging.AbstractionsMicrosoft.Extensions.OptionsStackExchange.Redis

13. Resumen de Configuración y Registro en DI#

Puntos de Entrada DI y Configuración Verificados

  • CachingServiceCollectionExtensions.AddCacheInvalidator

    Registers the canonical `CacheInvalidator` as the default scoped `ICacheInvalidator`.

  • CachingServiceCollectionExtensions.AddCacheInvalidator<TInvalidator>

    Registers a custom implementation of `ICacheInvalidator` in the service collection.

  • CachingServiceCollectionExtensions.AddHybridCache

    Registers a `HybridCacheProvider` that coordinates an L1 local cache with an L2 distributed cache.

  • CachingServiceCollectionExtensions.AddMemoryCacheProvider

    Registers the `MemoryCacheProvider` as the default singleton `ICacheProvider` and `ITaggedCacheProvider`.

  • CachingServiceCollectionExtensions.AddTenantPartitionedCache

    Decorates an existing `ICacheProvider` registration with `TenantPartitionedCacheProvider` using the specified tenant resolution delegate.

  • CachingRedisServiceCollectionExtensions.AddRedisCaching

    Adds 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ónOrigenFecha de PublicaciónResumen
v1.0.0 ↗github2026-09-22Ecosystem 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 ↗nuget2026-09-22Published EricksonLopez.Caching 1.0.0 to NuGet.org.

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#

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).

Buscar en el Ecosistema EricksonLopez.*

Escribe el nombre de una librería, ID de paquete NuGet, tipo .NET o concepto arquitectónico para buscar en el portal.