NCache.OSS.DistributedLock
5.3.6.1
dotnet add package NCache.OSS.DistributedLock --version 5.3.6.1
NuGet\Install-Package NCache.OSS.DistributedLock -Version 5.3.6.1
<PackageReference Include="NCache.OSS.DistributedLock" Version="5.3.6.1" />
<PackageVersion Include="NCache.OSS.DistributedLock" Version="5.3.6.1" />
<PackageReference Include="NCache.OSS.DistributedLock" />
paket add NCache.OSS.DistributedLock --version 5.3.6.1
#r "nuget: NCache.OSS.DistributedLock, 5.3.6.1"
#:package NCache.OSS.DistributedLock@5.3.6.1
#addin nuget:?package=NCache.OSS.DistributedLock&version=5.3.6.1
#tool nuget:?package=NCache.OSS.DistributedLock&version=5.3.6.1
NCache.OSS.DistributedLock
An NCache implementation of the DistributedLock API, providing distributed locking, semaphore, and reader-writer lock primitives backed by an NCache cluster. This package plugs into the DistributedLock.Core abstractions (IDistributedLock, IDistributedSemaphore, IDistributedReaderWriterLock), so it can be used as a drop-in synchronization provider anywhere those interfaces are expected — with lock keys auto-expired in NCache as a safety net against processes that crash while holding a lock.
Installation
Install-Package NCache.OSS.DistributedLock
or, using the .NET CLI:
dotnet add package NCache.OSS.DistributedLock
What is Installed
Installing this package adds the following NCache configuration files to your project:
- client.ncconf — Defines the cache client settings, including the cache name and the list of server nodes the client connects to.
- config.ncconf — Contains the cache configuration (cache topology, partitions, eviction policy, etc.) used when the cache is created/registered.
Prerequisites
- Targets .NET Standard 2.0.
- An NCache OSS 5.3.6.1 (or later) server should be up and running, with the target cache already created/registered on it.
Getting Started
Setting up NCache
Before running your application (If NCache is not installed on current machine), you need to update client.ncconf so the client knows which cache to connect to and where to find it:
- Open
client.ncconf. - Locate the cache entry named
myreplicatedcacheand rename it to the name of your actual cache (the cache you created/registered on the NCache server). - Under the
serversettings, update the server address to point to one of the nodes in the cluster where that cache is running.
Example:
<cache id="myreplicatedcache" ... >
<server name="10.0.5.1" ... />
</cache>
Change myreplicatedcache → YourCacheName, and 10.0.5.1 → the IP/hostname of a node hosting YourCacheName.
Setting up Package
Connect to your NCache cache and create a synchronization provider:
using Alachisoft.NCache.Client; using NCache.DistributedLock.Providers; ICache cache = CacheManager.GetCache("YourCacheName"); var provider = new NCacheDistributedSynchronizationProvider(cache);NCacheDistributedSynchronizationProviderimplementsIDistributedLockProvider,IDistributedSemaphoreProvider, andIDistributedReaderWriterLockProvider, so it can create any of the three primitives below.Distributed Lock — mutual-exclusion lock backed by an NCache key:
using NCache.DistributedLock.Locks; var distributedLock = new NCacheDistributedLock("my-resource-name", cache); // or: var distributedLock = provider.CreateLock("my-resource-name"); using (var handle = distributedLock.Acquire(TimeSpan.FromSeconds(30))) { // critical section } // lock is released when the handle is disposedDistributed Semaphore — bounded-count lock allowing up to
Nconcurrent holders, with automatic cleanup of acquisitions left behind by crashed processes:var semaphore = new NCacheDistributedSemaphore("my-resource-name", maxCount: 3, cache); // or: var semaphore = provider.CreateSemaphore("my-resource-name", 3); using (var handle = semaphore.Acquire(TimeSpan.FromSeconds(30))) { // up to 3 concurrent holders allowed }Distributed Reader-Writer Lock — multiple concurrent readers or a single exclusive writer, with writers waiting for active readers to release before acquiring:
var rwLock = new NCacheDistributedReaderWriterLock("my-resource-name", cache); // or: var rwLock = provider.CreateReaderWriterLock("my-resource-name"); using (var readHandle = rwLock.AcquireReadLock(TimeSpan.FromSeconds(30))) { // shared read access } using (var writeHandle = rwLock.AcquireWriteLock(TimeSpan.FromSeconds(30))) { // exclusive write access }
Configuration
Connection to the cache (server list, timeouts, retries, security) is configured through client.ncconf, or programmatically via CacheConnectionOptions when calling CacheManager.GetCache(). No additional JSON or code-based configuration is required beyond obtaining the ICache instance shown above.
Resources
Technical Support
This is the Open Source (OSS) edition of NCache and is provided as is. Technical support is not provided for the OSS version.
If you encounter an issue, you are encouraged to investigate the source code, consult the available documentation, or engage with the open-source community. Feature requests and support services are available only with the Enterprise edition of NCache.
License
Copyright © 2026 Alachisoft. All rights reserved.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Alachisoft.NCache.Opensource.SDK (>= 5.3.6.2)
- DistributedLock.Core (>= 1.0.9)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.9)
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 |
|---|---|---|
| 5.3.6.1 | 119 | 8/18/2026 |