Headless.Caching.Redis
0.4.15
dotnet add package Headless.Caching.Redis --version 0.4.15
NuGet\Install-Package Headless.Caching.Redis -Version 0.4.15
<PackageReference Include="Headless.Caching.Redis" Version="0.4.15" />
<PackageVersion Include="Headless.Caching.Redis" Version="0.4.15" />
<PackageReference Include="Headless.Caching.Redis" />
paket add Headless.Caching.Redis --version 0.4.15
#r "nuget: Headless.Caching.Redis, 0.4.15"
#:package Headless.Caching.Redis@0.4.15
#addin nuget:?package=Headless.Caching.Redis&version=0.4.15
#tool nuget:?package=Headless.Caching.Redis&version=0.4.15
Headless.Caching.Redis
Redis distributed cache implementation for multi-instance applications.
Problem Solved
Provides distributed caching using Redis via the unified ICache abstraction, enabling cache sharing across multiple application instances.
Key Features
- Full
IDistributedCacheimplementation using StackExchange.Redis - Supports strongly-typed
IDistributedCache<T>pattern - Prefix-based key management
- Atomic operations (increment, compare-and-swap, SetIfHigher/Lower)
- Set/list operations with pagination
- Lua scripts for atomic multi-key operations
- Redis Cluster support
Installation
dotnet add package Headless.Caching.Redis
Quick Start
var builder = WebApplication.CreateBuilder(args);
// Option 1: Use connection string
builder.Services.AddRedisCaching(options =>
{
options.ConnectionString = "localhost:6379";
});
// Option 2: Use existing IConnectionMultiplexer
builder.Services.AddRedisCaching();
Configuration
appsettings.json
{
"Redis": {
"ConnectionString": "localhost:6379,password=secret,ssl=true"
}
}
Options
options.ConnectionString = "localhost:6379";
options.KeyPrefix = "myapp:";
Cancellation Token Behavior
Cancellation is checked at the start of each operation. Once an operation begins, it completes without interruption:
| Operation Type | Cancellation Behavior |
|---|---|
Single-key ops (GetAsync, UpsertAsync, etc.) |
Checked before Redis call; operation completes atomically |
Batch ops (UpsertAllAsync, RemoveAllAsync) |
Checked before batch starts; all keys processed atomically |
SCAN-based ops (RemoveByPrefixAsync, GetAllKeysByPrefixAsync) |
Cancellable during iteration (unbounded key sets) |
This design ensures consumers never observe partial results from batch operations.
Note: StackExchange.Redis doesn't support
CancellationTokenin its API. Timeouts are configured viaConfigurationOptions.SyncTimeoutandAsyncTimeout.
Dependencies
Headless.Caching.AbstractionsHeadless.HostingHeadless.RedisHeadless.Serializer.JsonStackExchange.Redis
Side Effects
- Registers
IDistributedCacheas singleton - Registers
IDistributedCache<T>as singleton - Uses existing
IConnectionMultiplexerif registered, otherwise creates one
| 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
- CommunityToolkit.HighPerformance (>= 8.4.2)
- FluentValidation (>= 12.1.1)
- Headless.Caching.Abstractions (>= 0.4.15)
- Headless.Hosting (>= 0.4.15)
- Headless.Redis (>= 0.4.15)
- Headless.Serializer.Json (>= 0.4.15)
- Humanizer.Core (>= 3.0.10)
- IdGen (>= 3.0.7)
- JetBrains.Annotations (>= 2025.2.4)
- libphonenumber-csharp (>= 9.0.30)
- Microsoft.Bcl.TimeProvider (>= 10.0.8)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Hosting (>= 10.0.8)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Logging (>= 10.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Logging.Console (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.8)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.8)
- morelinq (>= 4.4.0)
- Nito.AsyncEx (>= 5.1.2)
- Nito.Disposables (>= 2.5.0)
- Polly.Core (>= 8.6.6)
- Scrutor (>= 7.0.0)
- StackExchange.Redis (>= 2.13.1)
- System.Reactive (>= 6.1.0)
- TimeZoneConverter (>= 7.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.