Franz.Common.Caching 1.7.7

There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Franz.Common.Caching" Version="1.7.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Franz.Common.Caching" Version="1.7.7" />
                    
Directory.Packages.props
<PackageReference Include="Franz.Common.Caching" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Franz.Common.Caching --version 1.7.7
                    
#r "nuget: Franz.Common.Caching, 1.7.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Franz.Common.Caching@1.7.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Franz.Common.Caching&version=1.7.7
                    
Install as a Cake Addin
#tool nuget:?package=Franz.Common.Caching&version=1.7.7
                    
Install as a Cake Tool

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

    • ICacheProvider
    • ICacheKeyStrategy
    • ISettingsCache
    • 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

    • MemoryCacheProvider
    • DistributedCacheProvider
    • RedisCacheProvider
  • ๐Ÿ”‘ 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

      • FranzCorrelationId
      • FranzCacheKey
      • FranzCacheHit
    • 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")
    );
});
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_hits
  • franz_cache_misses
  • franz_cache_lookup_latency_ms

OpenTelemetry Trace Tags

  • franz.cache.key
  • franz.cache.hit
  • franz.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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed