Soenneker.Redis.Lock 11.0.2990

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

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Redis.Lock

Provides expiring Redis locks with ownership-safe acquisition and release.

Installation

dotnet add package Soenneker.Redis.Lock

Registration

using Soenneker.Redis.Lock.Registrars;

services.AddRedisLockUtilAsScoped();

Registration includes Soenneker.Redis.Util; configure its Redis connection before resolving IRedisLockUtil.

Acquire a lock

using Soenneker.Redis.Lock;
using Soenneker.Redis.Lock.Abstract;

RedisLockHandle? handle = await redisLocks.TryLock(
    "orders:42:fulfill",
    TimeSpan.FromSeconds(30),
    cancellationToken);

if (handle is null)
    return; // another owner holds the lock

await using (handle)
{
    await FulfillOrder(cancellationToken);
}

TryLock writes a unique ownership token only when the key does not exist. Disposing the handle removes the key only if that token still matches, so an expired lock acquired by another process is not released accidentally.

Choose an expiration longer than the protected operation. This package does not renew leases and does not issue fencing tokens; if an operation can outlive its lease, an old owner can continue running after a new owner acquires the key. For correctness-critical writes, add a fencing/version check in the protected resource.

Lower-level operations

  • Check is a point-in-time existence check, not proof that the caller owns a lock.
  • Lock unconditionally writes the shared value 1, overwriting any existing value. Prefer TryLock for mutual exclusion.
  • Unlock(lockName) releases only a value written by Lock; Unlock(lockName, lockValue) performs a compare-and-delete.
  • ForceUnlock and ForceUnlockAll delete without checking ownership and should be reserved for recovery/administration.

Cancellation can stop a pending call, but it does not undo a lock command Redis already accepted.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Soenneker.Redis.Lock:

Package Downloads
Soenneker.Redis.Suite

A concoction of Redis utilities and libraries

Soenneker.Runners.Redis.Locks

A task runner that uses IRedisLockUtil to release a set of distributed Redis locks, typically when the application starts

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.2990 237 11/19/2026
11.0.2988 136 11/18/2026
11.0.2985 119 11/18/2026
11.0.2984 86 11/18/2026
11.0.2983 130 11/18/2026
11.0.2982 115 11/18/2026
11.0.2981 146 11/15/2026
11.0.2980 139 11/15/2026
11.0.2979 132 11/15/2026
11.0.2978 175 11/12/2026
11.0.2976 180 11/11/2026
11.0.2973 157 11/11/2026
11.0.2972 109 11/11/2026
11.0.2970 149 11/11/2026
11.0.2969 259 11/3/2026
11.0.2968 107 11/3/2026
11.0.2967 137 11/3/2026
11.0.2966 112 11/3/2026
11.0.2965 123 11/3/2026
11.0.2964 121 11/3/2026
Loading failed

Updated Soenneker.Redis.Util to 11.0.5569