Provides a
FusionHybridCacheimplementation ofIHybridCachebacked by the ZiggyCreatures FusionCache library, bridging CoreEx caching contracts to FusionCache's L1/L2 hybrid and backplane capabilities.
CoreEx.Caching.FusionCache binds the IHybridCache abstraction defined in CoreEx to the open-source FusionCache library. Application code that depends on IHybridCache requires no changes; swapping in FusionHybridCache upgrades the backing store from the built-in MemoryOnlyHybridCache to FusionCache's full feature set, including a configurable L1 in-memory cache, an optional L2 distributed cache (e.g. Redis), a memory backplane for multi-node cache coherence, and tag-based invalidation.
The package is deliberately thin: FusionHybridCache delegates every cache operation to the underlying IFusionCache instance after applying key qualification via ICacheKeyProvider and translating HybridCacheEntryOptions into FusionCacheEntryOptions via FusionCacheExtensions.ToFusionCacheEntryOptions. The CacheStrategy enum governs which tiers participate in each operation — Local disables the distributed tier, Distributed disables the in-memory tier, and Hybrid (the default) uses both.
- 🧩
IHybridCacheimplementation:FusionHybridCachefulfils allIHybridCachecontract methods —TryGetByKeyAsync,GetOrDefaultByKeyAsync,GetOrCreateByKeyAsync,SetByKeyAsync,RemoveByKeyAsync, andRemoveByTagAsync— against anIFusionCacheinstance. - 🔄 Options translation:
FusionCacheExtensions.ToFusionCacheEntryOptionsmapsHybridCacheEntryOptions(LocalExpiration,DistributedExpiration,CacheStrategy,Tags) directly to aFusionCacheEntryOptionsinstance, includingSkipDistributedCache*andSkipMemoryCache*flags derived fromCacheStrategy. - 📦 L1/L2 and backplane support: relies on FusionCache's own backplane packages (
ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis,ZiggyCreatures.FusionCache.Backplane.Memory) and serializer (ZiggyCreatures.FusionCache.Serialization.SystemTextJson) that are bundled as transitive dependencies. - 🏷 Tag-based invalidation:
RemoveByTagAsyncdelegates to FusionCache's native tag-eviction API, allowing entire categories of cache entries to be invalidated by a single call. - 🔧 Single-line DI registration:
AddFusionHybridCache()registersFusionHybridCacheas the scopedIHybridCacheservice; composing it with FusionCache's ownAddFusionCache()setup is the only wiring required. - Entry-options escape hatch:
FusionHybridCache.ConfigureEntryOptions(Action<FusionCacheEntryOptions>)accepts a fluent callback invoked on every translatedFusionCacheEntryOptionsbefore use, giving access to any FusionCache-specific setting not covered byHybridCacheEntryOptions.
| Type | Description |
|---|---|
FusionHybridCache |
IHybridCache implementation backed by IFusionCache; qualifies keys via ICacheKeyProvider, translates options, and supports a per-instance ConfigureEntryOptions callback for advanced FusionCache settings. |
FusionCacheExtensions |
Static extension class; ToFusionCacheEntryOptions(HybridCacheEntryOptions?) performs the CacheStrategy-aware options translation. |
CoreEx- DefinesIHybridCache,HybridCacheEntryOptions,CacheStrategy, andICacheKeyProviderthat this package implements and consumes.
- ZiggyCreatures FusionCache — the underlying caching library.
- FusionCache backplane documentation — configuring Redis or memory backplanes for multi-node coherence.
An AGENTS.md file is included with this package. AI coding assistants (GitHub Copilot, Claude, Cursor, etc.) that support workspace-injected package documentation will automatically surface concise usage guidance, code examples, and Do Not rules for this package without requiring a local CoreEx checkout.