DKNet.AspCore.Idempotency.RedisStore 10.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package DKNet.AspCore.Idempotency.RedisStore --version 10.1.2
                    
NuGet\Install-Package DKNet.AspCore.Idempotency.RedisStore -Version 10.1.2
                    
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="DKNet.AspCore.Idempotency.RedisStore" Version="10.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DKNet.AspCore.Idempotency.RedisStore" Version="10.1.2" />
                    
Directory.Packages.props
<PackageReference Include="DKNet.AspCore.Idempotency.RedisStore" />
                    
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 DKNet.AspCore.Idempotency.RedisStore --version 10.1.2
                    
#r "nuget: DKNet.AspCore.Idempotency.RedisStore, 10.1.2"
                    
#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 DKNet.AspCore.Idempotency.RedisStore@10.1.2
                    
#: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=DKNet.AspCore.Idempotency.RedisStore&version=10.1.2
                    
Install as a Cake Addin
#tool nuget:?package=DKNet.AspCore.Idempotency.RedisStore&version=10.1.2
                    
Install as a Cake Tool

DKNet.AspCore.Idempotency.RedisStore

Redis persistent storage implementation for DKNet.AspCore.Idempotency.

Overview

This library provides a Redis-backed storage implementation for idempotency keys, replacing the default distributed cache storage with an atomic store based on StackExchange.Redis.

Features

  • Atomic Reservation: SET NX guarantees only one caller reserves a key
  • Persistent Storage: Idempotency keys survive as long as configured in Redis
  • Concurrent-Safe: No check-then-act race window
  • Fast Lookups: In-memory speed for key existence checks

Installation

dotnet add package DKNet.AspCore.Idempotency.RedisStore

Quick Start

1. Configure in Program.cs

using DKNet.AspCore.Idempotency.RedisStore;

var builder = WebApplication.CreateBuilder(args);

// Register Redis idempotency storage
builder.Services.AddIdempotencyWithRedisStore(
    builder.Configuration.GetConnectionString("Redis")!,
    options =>
    {
        options.Expiration = TimeSpan.FromHours(24);
    });

var app = builder.Build();
app.Run();

2. Configure Connection String

appsettings.json:

{
  "ConnectionStrings": {
    "Redis": "localhost:6379"
  }
}

3. Use Idempotency in Endpoints

using DKNet.AspCore.Idempotency;

app.MapPost("/orders", CreateOrder)
    .RequiredIdempotentKey();

Configuration Options

IdempotencyOptions

Option Type Default Description
Expiration TimeSpan 4 hours How long to keep completed idempotency keys in Redis
InFlightReservationTimeout TimeSpan 30 seconds How long an in-flight reservation placeholder is honoured
JsonSerializerOptions JsonSerializerOptions Camel case Customizes JSON serialization for cached responses

Example Configuration

builder.Services.AddIdempotencyWithRedisStore(
    connectionString,
    options =>
    {
        options.Expiration = TimeSpan.FromHours(48);
        options.InFlightReservationTimeout = TimeSpan.FromMinutes(1);
    });

Using an Existing Connection Multiplexer

If your application already configures IConnectionMultiplexer, pass it directly:

builder.Services.AddIdempotencyRedisStore(existingMultiplexer);
builder.Services.AddIdempotentKey<IdempotencyRedisStore>();

Concurrency Handling

The library handles concurrent duplicate requests safely using Redis SET NX:

Request A: SET key NX → Success
Request B: SET key NX → Failure
Request B: GET key → Returns A's reservation or cached response

The atomic SET NX operation eliminates the check-then-act race window present in the default distributed-cache store.

Requirements

  • .NET 10.0+
  • Redis 5.0+ (or Redis-compatible cache such as Azure Cache for Redis)
  • DKNet.AspCore.Idempotency (automatically included)

License

MIT License - see LICENSE file for details.

Support

For issues and questions, please open an issue on the GitHub repository.

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
10.1.12 36 8/25/2026
10.1.11 46 8/24/2026
10.1.10 55 8/22/2026
10.1.9 63 8/22/2026
10.1.8 49 8/21/2026
10.1.7 64 8/21/2026
10.1.6 50 8/21/2026
10.1.5 57 8/20/2026
10.1.4 55 8/20/2026
10.1.3 57 8/19/2026
10.1.2 55 8/19/2026
10.1.1 52 8/19/2026
10.0.36 62 8/18/2026