MKS.KeyedLocking.Abstractions 1.0.0

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

MKS.KeyedLocking.Abstractions

Core abstractions for keyed mutual exclusion locking in the MKS system.

Features

  • IKeyedLockService - Contract for exclusive locks by string key
  • Async acquire/release - Returns IAsyncDisposable handles for await using patterns
  • TryAcquire - Non-throwing acquisition with null return on timeout
  • LockAcquisitionTimeoutException - Typed exception for failed acquisitions
  • No dependencies - Pure abstractions package

Installation

dotnet add package MKS.KeyedLocking.Abstractions

Usage

This package defines contracts only. Choose an implementation package:

  • MKS.KeyedLocking.InMemory - Single-process locking
  • MKS.KeyedLocking.Redis - Distributed locking via Redis
  • MKS.KeyedLocking.Oracle - Distributed locking via Oracle DBMS_LOCK
  • MKS.KeyedLocking.Composite - Local in-memory barrier over a distributed backend
  • MKS.KeyedLocking.MediatR - MediatR pipeline filters for automatic locking

Example

public class PaymentService(IKeyedLockService lockService)
{
    public async Task ProcessPaymentAsync(string paymentId, CancellationToken cancellationToken)
    {
        await using (await lockService.AcquireAsync($"payment:{paymentId}", TimeSpan.FromSeconds(30), cancellationToken))
        {
            // critical section
        }
    }
}
Package Description
MKS.KeyedLocking.InMemory In-process SemaphoreSlim-based locking
MKS.KeyedLocking.Redis StackExchange.Redis distributed locks
MKS.KeyedLocking.Oracle Oracle DBMS_LOCK user locks
MKS.KeyedLocking.Composite Local queue + distributed lock decorator
MKS.KeyedLocking.MediatR MediatR pipeline integration
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.
  • net10.0

    • No dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on MKS.KeyedLocking.Abstractions:

Package Downloads
MKS.KeyedLocking.InMemory

In-process keyed locking implementation for the MKS system. Uses SemaphoreSlim per key with reference counting to avoid memory leaks on unused keys.

MKS.KeyedLocking.Oracle

Distributed keyed locking via Oracle DBMS_LOCK user locks for the MKS system. Session-bound locks with automatic cleanup on disconnect.

MKS.KeyedLocking.MediatR

MediatR pipeline integration for MKS keyed locking. Provides generic KeyedLockFilter base class for per-command/query lock configuration without handler boilerplate.

MKS.KeyedLocking.Composite

Composite keyed locking decorator for the MKS system. Serializes local contention via in-memory semaphores before acquiring a distributed lock (Redis/Oracle).

MKS.KeyedLocking.Redis

Distributed keyed locking via Redis (StackExchange.Redis) for the MKS system. Uses LockTake/LockRelease/LockExtend with automatic TTL renewal.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 186 7/6/2026

Version 1.0.0: Initial release.
      Provides IKeyedLockService and LockAcquisitionTimeoutException.