EricksonLopez.Caching
dotnet-caching · Performance & Caching
On this page (20 sections)
1. Identity, Tier & Maturity Profile#
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<PackageReference Include="EricksonLopez.Caching" Version="1.0.0" /><PackageVersion Include="EricksonLopez.Caching" Version="1.0.0" />4. Verified Ecosystem Metrics#
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 ID | Status | NuGet / Local | TFMs | AOT Status | Downloads | Description |
|---|---|---|---|---|---|---|
| EricksonLopez.CachingPrimary | Published | v1.0.0 / v2.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 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 | Published | v1.0.0 / v2.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 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. 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#
Rendering diagram…
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
View accessible text summary and structure
1 upstream library dependencies and 1 downstream dependent libraries verified in dependencies.json.
| Direction | Library | Tier | Relationship Kinds |
|---|---|---|---|
| Upstream | EricksonLopez.Result | L0 | Adapter, Compile-Time, NuGet Package |
| Downstream | EricksonLopez.Mediator | L2 | Adapter |
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 & Native AOT / Trimming Matrix#
MSBuild `.csproj` inspection across 2 packages: 2 Full, 0 Partial, 0 Incompatible, 0 NotApplicable (analyzers/generators).
| Package ID | IsAotCompatible | EnableTrimAnalyzer | Verified AOT Status | 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. Upstream Dependencies & Downstream Dependents#
Upstream Dependencies (1)
Downstream Dependents (1)
12. Optional Adapters & Third-Party Integrations#
Internal Adapter Edges & Integration Packages
- EricksonLopez.Caching→ EricksonLopez.Result (EricksonLopez.Result)
- EricksonLopez.Mediator.Caching (EricksonLopez.Mediator)→ EricksonLopez.Caching
Verified External NuGet Dependencies (4)
13. Configuration & DI Registration Summary#
Verified DI & Configuration Entry Points
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.
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.
| Version | Source | Published Date | Summary |
|---|---|---|---|
| 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. Complementary & Related Libraries#
Libraries in the same tier, architectural layer, or directly paired via dependency edges.
17. Documentation, API Reference & Portal Links#
Conceptual Documentation (Starlight) →
Extracted XML API Reference →
2 namespaces · 17 types · 148 members
Ecosystem Dependency Map →
Learning Center & Handbook →
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).