NCache.OSS.DistributedLock 5.3.603

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

NCache DistributedLock Integration

NCache integration for DistributedLock. This package provides distributed locks, semaphores and reader-writer locks backed by an NCache cluster. It implements the DistributedLock.Core abstractions (IDistributedLock, IDistributedSemaphore, IDistributedReaderWriterLock), so it can be used anywhere those interfaces are expected, and lock keys expire 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

  • .NET Standard 2.0 compatible application.
  • An NCache 5.3.603 (or later) server should be up and running, with the target cache already created/registered on it.

Getting Started

Setting up NCache

The servers can be given in code (shown below). If you leave ServerList empty, the client reads them from a client.ncconf in your project; in that case, if NCache is not installed on the current machine, add one and set the cache id to your cache name:

<configuration>
  <ncache-server port="9800" />
  <cache id="defaultCache" enable-client-logs="False" log-level="error">
    <server name="10.0.0.1" />
  </cache>
</configuration>

Change defaultCache to the name of your actual cache (the cache you created/registered on the NCache server), and 10.0.0.1 to the IP/hostname of a node hosting it. You can skip this file by passing a CacheConnectionOptions server list to CacheManager.GetCache instead (shown below).

Setting up Package

Build and connect an NCache ICache using the NCache SDK, then create a synchronization provider from it:

using Alachisoft.NCache.Client;
using NCache.DistributedLock.Providers;

ICache cache = CacheManager.GetCache("defaultCache");

var provider = new NCacheDistributedSynchronizationProvider(cache);

NCacheDistributedSynchronizationProvider implements IDistributedLockProvider, IDistributedSemaphoreProvider and IDistributedReaderWriterLockProvider, so it can create any of the three primitives below. Because the provider takes an already-configured ICache, you can build that instance however you need, for example with CacheManager.GetCache and a CacheConnectionOptions server list instead of client.ncconf.

Distributed lock — mutual exclusion 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
}
// the lock is released when the handle is disposed

Distributed semaphore — allows up to N concurrent 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
}

Distributed reader-writer lock — many concurrent readers or one exclusive writer; writers wait for active readers to release:

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

Configure the connection to NCache through client.ncconf, or programmatically by passing CacheConnectionOptions to CacheManager.GetCache. The cache must already exist on the server. No other configuration is needed beyond obtaining the ICache instance shown above.

The integration provides:

  • NCacheDistributedSynchronizationProvider — Creates locks, semaphores and reader-writer locks from an ICache.
  • NCacheDistributedLock — IDistributedLock implementation.
  • NCacheDistributedSemaphore — IDistributedSemaphore implementation.
  • NCacheDistributedReaderWriterLock — IDistributedReaderWriterLock implementation.

Each Acquire call takes an optional timeout and returns a handle; disposing the handle releases the lock.

Resources

Technical Support

Alachisoft provides various technical support resources.

Visit the Alachisoft Support Center to select a support resource appropriate for your issue.

To request additional features or report a documentation discrepancy, contact support@alachisoft.com.

License

Copyright © 2026 Alachisoft. All rights reserved.

Product 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. 
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 NCache.OSS.DistributedLock:

Package Downloads
NCache.OSS.Dapper

NCache Opensource extension for Dapper providing distributed caching of database queries.

NCache.OSS.Quartz

NCache-backed IJobStore for Quartz.NET, targeting NCache Open Source Edition.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.3.603 229 10/23/2026
5.3.6.1 156 8/18/2026