EricksonLopez.Caching

dotnet-caching · Performance & Caching

On this page (20 sections)

1. Identity, Tier & Maturity Profile#

L2 Cross-Cutting & ReliabilityStableMaintenance: MaintainedAOT: FullMIT LicenseConfidence: HIGH
ApplicationCross-Cuttingnet8.0net9.0net10.0

2. Value Proposition & Problem Solved#

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.

Standard IMemoryCache and IDistributedCache implementations lack single-flight stampede protection, leak Redis exceptions into business handlers, and risk wildcard cache wipeouts.

3. Quick Install#

Primary package: EricksonLopez.Caching

dotnet add package EricksonLopez.Caching --version 1.0.0
Also published in this family:
EricksonLopez.Caching.Redis

4. Verified Ecosystem Metrics#

v1.0.0
NuGet Published Version
v2.0.0
Repo HEAD Version
733
NuGet Downloads
2
Packable Packages
148
Public API Members
0
Benchmark Rows (RyuJIT)

Snapshot retrieved UTC: 2026-12-01

5. When to Use & When Not to Use#

When to use

  • You want L1 Memory + L2 Redis HybridCacheProvider with stampede locking, tagged invalidation, and Result<T> error handling.

When NOT to use

  • You need an in-process dictionary without TTL, tag invalidation, or distributed Redis coordination.

6. Core Capabilities & Design Invariants#

Dual-Scope Stampede Protection

Single-flight execution via per-key SemaphoreSlim locally and atomic Redis SETNX lease locking across pods.

Tagged Invalidation & Tenant Partitioning

Atomic tag eviction via Redis Lua scripts plus AddTenantPartitionedCache key isolation.

7. Included NuGet Packages & Adapters#

Package IDStatusNuGet / LocalTFMsAOT StatusDownloadsDescription
EricksonLopez.CachingPrimaryPublishedv1.0.0 / v2.0.0net8.0, net9.0, net10.0AOT: Full597High-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.RedisPublishedv1.0.0 / v2.0.0net8.0, net9.0, net10.0AOT: Full136Redis 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. Quick Start Code Example#

Grounded in verified public APIs from EricksonLopez.Caching. Compile with `<ImplicitUsings>disable</ImplicitUsings>` and explicit imports.

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. Architecture & Dependency Flow#

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
EricksonLopez.Caching Dependency Topology1 upstream library dependencies and 1 downstream dependent libraries verified in dependencies.json.
View accessible text summary and structure

1 upstream library dependencies and 1 downstream dependent libraries verified in dependencies.json.

DirectionLibraryTierRelationship Kinds
UpstreamEricksonLopez.ResultL0Adapter, Compile-Time, NuGet Package
DownstreamEricksonLopez.MediatorL2Adapter
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 & Native AOT / Trimming Matrix#

MSBuild `.csproj` inspection across 2 packages: 2 Full, 0 Partial, 0 Incompatible, 0 NotApplicable (analyzers/generators).

Package IDIsAotCompatibleEnableTrimAnalyzerVerified AOT StatusTarget Frameworks
EricksonLopez.CachingtruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.Caching.RedistruetrueFullnet8.0, net9.0, net10.0

11. Upstream Dependencies & Downstream Dependents#

Upstream Dependencies (1)

Downstream Dependents (1)

12. Optional Adapters & Third-Party Integrations#

Internal Adapter Edges & Integration Packages

Verified External NuGet Dependencies (4)

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

13. Configuration & DI Registration Summary#

Verified DI & Configuration Entry Points

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

Key Public Types & Contracts

  • 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. Verified Performance Benchmarks#

All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).

No non-MEGA-AUDIT `BenchmarkDotNet.Artifacts` files were verified for this library in the snapshot (`hasBenchmarks: false`).

15. Release History & NuGet vs Repo Status#

Version lag detected: NuGet.org latest published version is v1.0.0, while local repository HEAD is at v2.0.0.

VersionSourcePublished DateSummary
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.

Libraries in the same tier, architectural layer, or directly paired via dependency edges.

17. Documentation, API Reference & Portal Links#

Per-library conceptual Starlight pages expand in M4; API Reference pages expand in M3.2.

18. Source Repository, License & Contributing#

Released under the MIT License. All assemblies follow EricksonLopez.* build invariants: explicit imports, strong-name signing (`EricksonLopez.snk`), and ASCII author metadata (`Erickson Lopez`).

19. Troubleshooting, Pitfalls & Migration Guidance#

  • Empty or whitespace cache keys, prefixes, and tags throw ArgumentException eagerly to prevent accidental full-cache invalidation.
  • Version lag detected: NuGet.org latest published version is v1.0.0, while local repository HEAD is at v2.0.0.

20. Quality & Verification Evidence#

Strong-Name Signing (`EricksonLopez.snk`)
EricksonLopez.snk
`ImplicitUsings=disable`
disable
XML Documentation Extraction
Verified (2 namespaces, 17 types, 148 members)
MSBuild AOT / Trim Attributes
2 Full / 0 Partial / 0 Incompatible / 0 N/A
BenchmarkDotNet Artifacts
0 total (0 measured, 0 na_error)

Explicit Verification Boundaries & Limitations

  • All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.