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
<PackageReference Include="MKS.KeyedLocking.Abstractions" Version="1.0.0" />
<PackageVersion Include="MKS.KeyedLocking.Abstractions" Version="1.0.0" />
<PackageReference Include="MKS.KeyedLocking.Abstractions" />
paket add MKS.KeyedLocking.Abstractions --version 1.0.0
#r "nuget: MKS.KeyedLocking.Abstractions, 1.0.0"
#:package MKS.KeyedLocking.Abstractions@1.0.0
#addin nuget:?package=MKS.KeyedLocking.Abstractions&version=1.0.0
#tool nuget:?package=MKS.KeyedLocking.Abstractions&version=1.0.0
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
IAsyncDisposablehandles forawait usingpatterns - 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 lockingMKS.KeyedLocking.Redis- Distributed locking via RedisMKS.KeyedLocking.Oracle- Distributed locking via Oracle DBMS_LOCKMKS.KeyedLocking.Composite- Local in-memory barrier over a distributed backendMKS.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
}
}
}
Related Packages
| 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 | Versions 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. |
-
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.