StackExchange.Redis.HybridCache
0.1.36-alpha
Prefix Reserved
dotnet add package StackExchange.Redis.HybridCache --version 0.1.36-alpha
NuGet\Install-Package StackExchange.Redis.HybridCache -Version 0.1.36-alpha
<PackageReference Include="StackExchange.Redis.HybridCache" Version="0.1.36-alpha" />
<PackageVersion Include="StackExchange.Redis.HybridCache" Version="0.1.36-alpha" />
<PackageReference Include="StackExchange.Redis.HybridCache" />
paket add StackExchange.Redis.HybridCache --version 0.1.36-alpha
#r "nuget: StackExchange.Redis.HybridCache, 0.1.36-alpha"
#:package StackExchange.Redis.HybridCache@0.1.36-alpha
#addin nuget:?package=StackExchange.Redis.HybridCache&version=0.1.36-alpha&prerelease
#tool nuget:?package=StackExchange.Redis.HybridCache&version=0.1.36-alpha&prerelease
StackExchange.Redis.HybridCache
A HybridCache
implementation built natively on
StackExchange.Redis v4 server-assisted client-side caching,
instead of layering the stock implementation over IDistributedCache.
Why: the stock pairing keeps two uncoordinated in-memory tiers (the multiplexer's client
cache and a MemoryCache L1), and IDistributedCache has no change notification, so key and
tag invalidation never reach other servers' L1. Redis has had the missing mechanism since 6.0
(CLIENT TRACKING); building directly on it gives one near cache and fleet-coherent
invalidation, while keeping the parts of the stock implementation worth keeping — the stampede
protection (query combination), the serialization pipeline, and the HybridCache contract
itself (from Microsoft.Extensions.Caching.Abstractions; swapping in this implementation is a
one-line DI change). Entries are plain redis strings with absolute expiry — sliding expiration
is deliberately unsupported (it is incompatible with client-side caching; the design notes
explain why) — and the payload envelope stays byte-compatible with the default implementation's,
given the same serializer configuration.
Status: functional, pre-release. The full
HybridCachesurface is implemented at feature parity with the stock implementation — stampede protection (query combination with shared cancellation and immutable/mutable value semantics), all entry flags, key/tag validation, tag invalidation (push-coherent, server-assisted), logging andEventSourcetelemetry with the stock event IDs,TimeProvidersupport — and the stock test suites have been inherited and pass. See docs/design.md for architecture and remaining phases, and docs/parity-plan.md for the parity inventory and the deliberate divergences.
Usage
dotnet add package StackExchange.Redis.HybridCache --prerelease
var config = ConfigurationOptions.Parse("localhost:6379");
config.Protocol = RedisProtocol.Resp3;
config.ClientCache = new CacheOptions { Prefixes = ["hc:"] }; // match KeyPrefix
services.AddSingleton<IConnectionMultiplexer>(await ConnectionMultiplexer.ConnectAsync(config));
services.AddRedisHybridCache(); // registers HybridCache; KeyPrefix defaults to "hc:"
public class SomeService(HybridCache cache)
{
public async Task<Customer> GetCustomerAsync(int id, CancellationToken ct = default)
=> await cache.GetOrCreateAsync(
$"customer/{id}",
async token => await LoadFromDatabaseAsync(id, token),
tags: ["customers"],
cancellationToken: ct);
}
Reads served from the client cache are local, synchronous and allocation-free; RemoveAsync
and RemoveByTagAsync invalidate every server's near cache via redis push invalidation. A
dedicated multiplexer for the cache is encouraged (client-side caching is connection-level) —
register it keyed with typeof(HybridCache) and it is preferred automatically. See
docs/usage.md for
configuration, degraded modes, serialization, and telemetry.
Layout
src/StackExchange.Redis.HybridCache/— the library (RedisHybridCache : HybridCache, options, DI registration)tests/StackExchange.Redis.HybridCache.Tests/— xunit.v3 on Microsoft.Testing.Platformdocs/design.md— design notes
A runnable active-vs-passive invalidation demo (this implementation against the in-box
HybridCache, console and interactive TUI) lives in the
demos repo.
Building
dotnet build
dotnet test
Requires the .NET 10 SDK (see global.json). Versioning is Nerdbank.GitVersioning
(version.json); packages are produced from src/.
License
MIT. Portions are derived from
dotnet/extensions (Microsoft.Extensions.Caching.Hybrid),
also MIT — see THIRD-PARTY-NOTICES.md.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- Microsoft.Bcl.TimeProvider (>= 10.0.13)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Options (>= 10.0.13)
- StackExchange.Redis (>= 4.0.165-alpha)
- System.Text.Json (>= 10.0.13)
-
.NETStandard 2.0
- Microsoft.Bcl.TimeProvider (>= 10.0.13)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Options (>= 10.0.13)
- StackExchange.Redis (>= 4.0.165-alpha)
- System.Text.Json (>= 10.0.13)
-
net10.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Options (>= 10.0.13)
- StackExchange.Redis (>= 4.0.165-alpha)
-
net8.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Options (>= 10.0.13)
- StackExchange.Redis (>= 4.0.165-alpha)
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 |
|---|---|---|
| 0.1.36-alpha | 0 | 11/13/2026 |
| 0.1.29-alpha | 35 | 11/12/2026 |