Franz.Common.Caching
2.0.1
See the version list below for details.
dotnet add package Franz.Common.Caching --version 2.0.1
NuGet\Install-Package Franz.Common.Caching -Version 2.0.1
<PackageReference Include="Franz.Common.Caching" Version="2.0.1" />
<PackageVersion Include="Franz.Common.Caching" Version="2.0.1" />
<PackageReference Include="Franz.Common.Caching" />
paket add Franz.Common.Caching --version 2.0.1
#r "nuget: Franz.Common.Caching, 2.0.1"
#:package Franz.Common.Caching@2.0.1
#addin nuget:?package=Franz.Common.Caching&version=2.0.1
#tool nuget:?package=Franz.Common.Caching&version=2.0.1
Hereβs an updated README for version 1.7.8, including all the observability improvements, metrics observer, logging + metrics observer, and Excel/export-ready observer youβve just implemented:
Franz.Common.Caching
A full-featured caching module for the Franz Framework. Provides unified cache abstractions, hybrid caching (L1 + L2), Mediator request caching, settings cache, and first-class observability via Serilog, OpenTelemetry, and custom metrics/log observers.
- Current Version: 2.0.1
- Target Framework: .NET 10.0
β¨ Features
π§± Unified abstractions
ICacheProviderICacheKeyStrategyISettingsCache- Single cache options model (TTL, sliding, priority, tags)
β‘ Hybrid caching support
- L1: In-memory (fast, local)
- L2: Distributed / Redis (durable, shared)
- Read-through + write-through behavior
- Optional local cache hinting
π§© Pluggable providers
MemoryCacheProviderDistributedCacheProviderRedisCacheProvider
π Flexible cache key strategies
- Default (type + normalized payload)
- Namespaced (domain separation)
- Custom strategies (drop-in)
π Mediator pipeline integration
- Automatic cache HIT / MISS detection
- Transparent response caching
- Per-request cache options (TTL, sliding, bypass)
- CQRS-aware (queries cached, commands skipped)
- Null response caching supported
π Observability out of the box
Serilog enrichment
FranzCorrelationIdFranzCacheKeyFranzCacheHit
OpenTelemetry metrics
- cache hits / misses
- lookup latency
OpenTelemetry trace tags
franz.cache.*
Observers
MetricsCacheObserverβ in-memory metrics, hits, sets, total cache weightLoggingMetricsObserverβ combines Serilog logging + metricsExcelCacheObserverβ export cache statistics (hits, misses, size) to Excel
π Plug-and-play DI extensions
AddFranzMemoryCaching()AddFranzDistributedCaching<T>()AddFranzRedisCaching()AddFranzHybridCaching()AddFranzMediatorCaching()AddObservableCaching()β enables any combination of observersAddLoggingCacheObserver()AddMetricsCacheObserver()AddLoggingMetricsObserver()AddExcelCacheObserver()β opt-in for Excel exports
Observers are opt-in. You can register any combination depending on telemetry/logging needs.
π¦ Installation
dotnet add package Franz.Common.Caching --version 1.7.8
π Quickstart
// Program.cs
builder.Services.AddFranzHybridCaching();
// Mediator caching
builder.Services.AddFranzMediatorCaching(opts =>
{
opts.DefaultTtl = TimeSpan.FromMinutes(10);
opts.ShouldCache = req => !req.GetType().Name.EndsWith("Command");
});
// Observers
builder.Services.AddObservableCaching()
.AddLoggingCacheObserver()
.AddMetricsCacheObserver()
.AddLoggingMetricsObserver()
.AddExcelCacheObserver(); // optional Excel export
π Observability Examples
Metrics Observer
Tracks per-key stats:
- Hits / Misses
- Last access / set time
- Estimated size in bytes
- Total cache weight
var snapshot = metricsObserver.Snapshot();
var totalWeight = snapshot.Values.Sum(x => x.EstimatedSizeBytes);
Logging + Metrics Observer
Combines Serilog logs + OpenTelemetry metrics:
{
"FranzCorrelationId": "af42c6...",
"FranzPipeline": "CachingPipeline",
"FranzCacheKey": "GetUserById:{\"Id\":42}",
"FranzCacheHit": true,
"Message": "Cache HIT for GetUserByIdQuery in 0.6ms"
}
Excel Observer
Exports relevant stats only (hits/misses/size) to Excel for offline analysis.
π Changelog
v2.0.1 β Internal Modernization
- Messaging and infrastructure refactored for async, thread-safety, and modern .NET 10 patterns.
- All APIs remain fully backward compatible.
- Tests, listeners, and pipeline components modernized.
1.7.8
- Added MetricsCacheObserver β in-memory hit/miss, per-key stats, total cache weight
- Added LoggingMetricsObserver β combines Serilog + metrics, tracks hits, sets, latency
- Added ExcelCacheObserver β export relevant cache stats to Excel
- Updated DI extensions β opt-in observer registration methods
- Exposed CurrentKeys property on observers for testability
- Observers integrated with Redis, Distributed, Memory caches
- Internal improvements for latency tracking in
CacheAccessDescriptor
1.7.7
- Unified cache options across all providers
- Hybrid cache provider stabilized (L1 + L2)
- Removed legacy entry options
- Provider internals aligned with Mediator pipeline
- Improved null caching semantics
- Documentation refresh
1.7.6
- Lazy infrastructure loading
- Redis startup stability improvements
1.6.20
- Upgraded to .NET 10.0
Perfect β we can make a small ASCII/flow diagram for the README thatβs simple, readable, and shows the cache β observers β outputs flow. Hereβs a suggestion you can drop right under the Observability section:
Cache Operation Flow
-------------------
βββββββββββββββββ
β ICacheProviderβ
βββββββββ¬ββββββββ
β OnCacheSet / OnCacheHit / OnCacheRemove
βΌ
ββββββββββββββββββββββ
β ObservableCacheProvider β
βββββββββ¬βββββββββββββ
β
βββββββββββΌββββββββββ
βΌ βΌ βΌ
βββββββββββββ ββββββββββββββββ βββββββββββββββββ
β Logging β β Metrics β β Excel Export β
β Observer β β Observer β β Observer β
βββββββββββββ ββββββββββββββββ βββββββββββββββββ
ICacheProviderβ executes cache operations (set, get, remove).ObservableCacheProviderβ wraps the cache provider and broadcasts to all registered observers.Observers can be:
- LoggingCacheObserver β Serilog / log enrichment
- MetricsCacheObserver β in-memory stats, hits, misses, cache weight
- LoggingMetricsObserver β combined logs + metrics
- ExcelCacheObserver β exports relevant stats to Excel
This makes it instantly clear how any cache action flows through the system and where the data ends up.
If you want, I can also make a slightly fancier Markdown/mermaid diagram that will render nicely on GitHub and looks professional in the README. Do you want me to do that too?
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- EPPlus (>= 8.5.0)
- Franz.Common.Mediator (>= 2.0.1)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Caching.Memory (>= 10.0.5)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.5)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.5)
- StackExchange.Redis (>= 2.12.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.2 | 59 | 3/30/2026 |
| 2.0.1 | 81 | 3/29/2026 |
| 1.7.8 | 90 | 3/2/2026 |
| 1.7.7 | 107 | 1/31/2026 |
| 1.7.6 | 97 | 1/22/2026 |
| 1.7.5 | 103 | 1/10/2026 |
| 1.7.4 | 122 | 12/27/2025 |
| 1.7.3 | 186 | 12/22/2025 |
| 1.7.2 | 186 | 12/21/2025 |
| 1.7.1 | 129 | 12/20/2025 |
| 1.7.0 | 293 | 12/16/2025 |
| 1.6.21 | 204 | 11/27/2025 |
| 1.6.19 | 168 | 10/25/2025 |
| 1.6.15 | 197 | 10/20/2025 |
| 1.6.14 | 197 | 10/15/2025 |
| 1.6.3 | 201 | 10/9/2025 |
| 1.6.2 | 203 | 10/7/2025 |
| 1.5.9 | 203 | 9/24/2025 |
| 1.5.4 | 245 | 9/23/2025 |
| 1.5.3 | 252 | 9/21/2025 |