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
                    
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="Headless.Caching.Redis" Version="0.4.15" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Headless.Caching.Redis" Version="0.4.15" />
                    
Directory.Packages.props
<PackageReference Include="Headless.Caching.Redis" />
                    
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 Headless.Caching.Redis --version 0.4.15
                    
#r "nuget: Headless.Caching.Redis, 0.4.15"
                    
#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 Headless.Caching.Redis@0.4.15
                    
#: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=Headless.Caching.Redis&version=0.4.15
                    
Install as a Cake Addin
#tool nuget:?package=Headless.Caching.Redis&version=0.4.15
                    
Install as a Cake Tool

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 IDistributedCache implementation 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 CancellationToken in its API. Timeouts are configured via ConfigurationOptions.SyncTimeout and AsyncTimeout.

Dependencies

  • Headless.Caching.Abstractions
  • Headless.Hosting
  • Headless.Redis
  • Headless.Serializer.Json
  • StackExchange.Redis

Side Effects

  • Registers IDistributedCache as singleton
  • Registers IDistributedCache<T> as singleton
  • Uses existing IConnectionMultiplexer if registered, otherwise creates one
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
0.4.15 88 5/18/2026
0.4.14 91 5/18/2026