Franz.Common.Caching
1.7.7
See the version list below for details.
dotnet add package Franz.Common.Caching --version 1.7.7
NuGet\Install-Package Franz.Common.Caching -Version 1.7.7
<PackageReference Include="Franz.Common.Caching" Version="1.7.7" />
<PackageVersion Include="Franz.Common.Caching" Version="1.7.7" />
<PackageReference Include="Franz.Common.Caching" />
paket add Franz.Common.Caching --version 1.7.7
#r "nuget: Franz.Common.Caching, 1.7.7"
#:package Franz.Common.Caching@1.7.7
#addin nuget:?package=Franz.Common.Caching&version=1.7.7
#tool nuget:?package=Franz.Common.Caching&version=1.7.7
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 and OpenTelemetry.
- Current Version: 1.7.7
- 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.*
๐ Plug-and-play DI extensions
AddFranzMemoryCaching()AddFranzDistributedCaching<T>()AddFranzRedisCaching()AddFranzHybridCaching()AddFranzMediatorCaching()
๐ฆ Installation
dotnet add package Franz.Common.Caching
๐ Quickstart
// Program.cs
builder.Services.AddFranzHybridCaching();
builder.Services.AddFranzMediatorCaching(opts =>
{
opts.DefaultTtl = TimeSpan.FromMinutes(10);
opts.ShouldCache = req => !req.GetType().Name.EndsWith("Command");
});
๐ง Cache Options (Unified)
public sealed class CacheOptions
{
public TimeSpan? Expiration { get; init; }
public TimeSpan? LocalCacheHint { get; init; }
public bool Sliding { get; init; }
public CachePriority Priority { get; init; } = CachePriority.Normal;
public string[]? Tags { get; init; }
}
โ Same options model used across memory, distributed, redis, and mediator pipeline โ Providers adapt internally โ no provider-specific leakage
๐งช Example Mediator Query
public record GetUserByIdQuery(int Id) : IQuery<User>;
- First execution โ MISS โ handler executes โ cached
- Subsequent executions โ HIT โ cached response returned
- Logs + metrics + traces emitted automatically
๐งฐ Providers
In-memory (L1)
services.AddFranzMemoryCaching();
Distributed (L2 โ SQL Server, NCache, etc.)
services.AddFranzDistributedCaching<SqlServerCache>();
Redis (L2)
// Simple
services.AddFranzRedisCaching("localhost:6379");
// Advanced (DI-driven)
services.AddFranzRedisCaching(sp =>
{
var cfg = sp.GetRequiredService<IConfiguration>();
return ConnectionMultiplexer.Connect(
cfg.GetConnectionString("Redis")
);
});
Hybrid (Recommended)
services.AddFranzHybridCaching();
- Memory โ Redis / Distributed
- Local cache warming
- Consistent invalidation flow
๐ Observability
Serilog (example)
{
"FranzCorrelationId": "af42c6...",
"FranzPipeline": "CachingPipeline",
"FranzCacheKey": "GetUserById:{\"Id\":42}",
"FranzCacheHit": true,
"Message": "Cache HIT for GetUserByIdQuery in 0.6ms"
}
OpenTelemetry Metrics
franz_cache_hitsfranz_cache_missesfranz_cache_lookup_latency_ms
OpenTelemetry Trace Tags
franz.cache.keyfranz.cache.hitfranz.cache.ttl_seconds
๐งญ Roadmap
- Hashed / compact cache keys (Redis-friendly)
- Tag-based invalidation
- Deeper integration with
Franz.Common.Settings - Optional async background refresh
๐ Changelog
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 (this file)
1.7.6
- Lazy infrastructure loading
- Redis startup stability improvements
1.6.20
- Upgraded to .NET 10.0
| 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
- Franz.Common.Mediator (>= 1.7.7)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Caching.Memory (>= 10.0.1)
- StackExchange.Redis (>= 2.10.1)
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 | 198 | 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 |