HmacManager.StackExchangeRedis 1.0.0

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

HmacManager.StackExchangeRedis

NuGet Version .NET

Atomic, Redis-backed replay protection for HmacManager.

The built-in Distributed nonce cache works through IDistributedCache, which has no conditional write, so two copies of a request reaching two instances at the same moment can both be accepted. This package claims each nonce with one SET NX instead: exactly one copy is accepted, however many instances share the Redis.

Targets net8.0 and net10.0.

📖 Documentation

Install

dotnet add package HmacManager.StackExchangeRedis

Use it

Policies on UseDistributedCache are protected by Redis; policies on UseMemoryCache keep the in-process cache.

builder.Services.AddHmacManager(options =>
{
    options.AddPolicy("MyPolicy", policy =>
    {
        policy.UsePublicKey(publicKey);
        policy.UsePrivateKey(privateKey);
        policy.UseDistributedCache(maxAgeInSeconds: 60);
    });
});

builder.Services.AddStackExchangeRedisNonceCache(options =>
    options.Configuration = "localhost:6379");

The options match AddStackExchangeRedisCache's — Configuration, ConfigurationOptions, ConnectionMultiplexerFactory and InstanceName — and the keys match the built-in cache's, so nonces recorded before switching stay claimed after it.

Log events

Id Level Event
1400 Warning A nonce claim failed: Redis unreachable, timed out or errored. The request fails.
1401 Warning The Redis connection was lost
1402 Information The Redis connection was restored
Product Compatible and additional computed target framework versions.
.NET 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. 
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
1.0.0 118 10/14/2026