Rwx.DistributedLocking.Redis 0.3.1

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

Rwx.DistributedLocking.Redis

Redis-backed implementation of Rwx.DistributedLocking.IDistributedLock, using a SET NX PX acquire and a Lua compare-and-delete release so a lock is only ever released by the handle that acquired it.

Install

dotnet add package Rwx.DistributedLocking.Redis --version 0.2.0

Quick start

Install Rwx.DistributedLocking.Abstractions in any application project that injects IDistributedLock.

using Rwx.DistributedLocking.Redis;

builder.Services.AddRwxDistributedLocking(builder.Configuration);
await using IDistributedLockHandle? handle = await distributedLock.TryAcquireAsync(
    "migrations:iam", timeout: TimeSpan.FromMinutes(2), cancellationToken);

if (handle is null)
{
    // another instance holds the lock — skip, don't retry forever
    return;
}

// protected work

The default connection-string name is Redis:

{
  "ConnectionStrings": {
    "Redis": "localhost:6379"
  },
  "DistributedLocking": {
    "LeaseDuration": "00:05:00",
    "RetryInterval": "00:00:00.250"
  }
}

Pass a different connection-string name as the third argument when needed. The module equivalent is RwxDistributedLockingModule. Opens its own IConnectionMultiplexer — independent of any connection Rwx.Caching.Redis manages internally.

Boundaries

Single-Redis lock (SET NX PX + token-checked release), not the multi-node Redlock algorithm — sufficient once LeaseDuration comfortably exceeds how long the protected work normally takes, so a crashed holder's lock still self-expires. Don't use this as a substitute for a database constraint when one is available.

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.3.1 242 7/26/2026
0.3.0 141 7/20/2026
0.2.2 166 7/14/2026
0.2.1 122 7/13/2026