Alachisoft.NCache.Opensource.SDK
5.3.603
dotnet add package Alachisoft.NCache.Opensource.SDK --version 5.3.603
NuGet\Install-Package Alachisoft.NCache.Opensource.SDK -Version 5.3.603
<PackageReference Include="Alachisoft.NCache.Opensource.SDK" Version="5.3.603" />
<PackageVersion Include="Alachisoft.NCache.Opensource.SDK" Version="5.3.603" />
<PackageReference Include="Alachisoft.NCache.Opensource.SDK" />
paket add Alachisoft.NCache.Opensource.SDK --version 5.3.603
#r "nuget: Alachisoft.NCache.Opensource.SDK, 5.3.603"
#:package Alachisoft.NCache.Opensource.SDK@5.3.603
#addin nuget:?package=Alachisoft.NCache.Opensource.SDK&version=5.3.603
#tool nuget:?package=Alachisoft.NCache.Opensource.SDK&version=5.3.603
Alachisoft.NCache.Opensource.SDK
This NCache SDK NuGet package is the complete package for using NCache Open Source with .NET. Essentially, it provides the client APIs required to build .NET applications with NCache.
Package Versions
| Package | Version |
|---|---|
| Alachisoft.NCache.Opensource.SDK | Open Source Edition |
Overview
The NCache Open Source SDK includes client libraries for the following:
CacheManager— Provides static methods for establishing connections to an NCache cache.ICache— Represents a cache instance and exposes APIs for CRUD operations, bulk operations, expiration, event notifications, Pub/Sub messaging, and other cache operations.CacheConnectionOptions— Configures how client applications connect to the cache, including server endpoints, retry behavior, timeouts, load balancing, and logging.CacheItem— Represents a cache entry together with metadata such as expiration and priority.IMessagingService— Provides Pub/Sub topics and cache-level event notifications, available throughICache.MessagingService.
Applications establish a connection by calling CacheManager.GetCache(), which returns an ICache instance. Once connected, the ICache interface provides access to all supported NCache operations, including storing and retrieving data, publishing messages, receiving notifications, and managing cache entries. Several of the features are highlighted below.
Key Features
- Distributed in-memory caching
- Basic and bulk CRUD operations
- Absolute and sliding expiration
- Cache item priority for eviction
- Runtime cache event notifications
- Pub/Sub messaging
- Client-side connection retries, load balancing, and client logging
What Is Installed
Installing the Alachisoft.NCache.Opensource.SDK package adds the NCache assemblies and configuration files required by a .NET application to connect to and use an NCache cache.
The following configuration files are copied to the application's output directory:
| File | Description |
|---|---|
| client.ncconf | Contains cache server and client connectivity information. |
| config.ncconf | Contains configuration for local InProc caches and InProc client caches. For a client cache, it also identifies the associated clustered cache. |
NCache first looks for these files in the application's local directory. If the required configuration is not available locally, it attempts to read it from the NCache installation directory. When NCache is not installed on the application machine, ensure that the local configuration files contain all required cache and connection information.
For .NET Core projects run from Visual Studio, edit the .ncconf files shown in Solution Explorer, build the solution, and then copy the .ncconf files from the bin folder to the project directory. This step is not required when the project is published and run through the dotnet command.
Prerequisites
Before using this package, ensure you have:
- Existing Cache: A running cache (e.g.,
defaultCache) must already be created on an NCache server. - .NET Version: The package targets .NET Standard 2.0 and .NET Framework 4.6.2. The recommended target framework is .NET 8.0. For all supported .NET versions, refer to Supported .NET Versions.
- NCache Installation: You must have NCache Open Source installed on your cache servers. For the client machine, you only need the client libraries.
- Cache Connectivity: Ensure network access to the cache servers.
Installation
Install the Alachisoft.NCache.Opensource.SDK package using either the NuGet Package Manager Console or the .NET CLI.
NuGet Package Manager Console
Install-Package Alachisoft.NCache.Opensource.SDK
.NET CLI
dotnet add package Alachisoft.NCache.Opensource.SDK
Connect to Cache
Use CacheManager.GetCache() to connect to an existing NCache cache. The method returns an ICache instance, which is used to perform cache operations.
using Alachisoft.NCache.Client;
ICache cache = CacheManager.GetCache("defaultCache");
You can also provide connection settings programmatically by using CacheConnectionOptions.
var connectionOptions = new CacheConnectionOptions
{
ServerList = new List<ServerInfo>
{
new ServerInfo("127.0.0.1")
}
};
ICache cache = CacheManager.GetCache("defaultCache", connectionOptions);
CacheConnectionOptions controls how the client application connects to NCache.
| Property | Description |
|---|---|
ServerList |
List of NCache server nodes used to establish the cache connection. |
ClientRequestTimeOut |
Maximum time the client waits for a response from the cache server. |
ConnectionTimeout |
Maximum time allowed for establishing a connection with a cache server. |
ConnectionRetries |
Number of times a failed connection attempt is retried. |
RetryInterval |
Time interval between connection retries. |
RetryConnectionDelay |
Delay before the client retries a connection to a lost server. |
LoadBalance |
Distributes client connections across the cache servers. |
ClientBindIP |
Local IP address the client binds to when connecting to the cache. |
AppName |
Application name reported to the cache server for this client. |
EnableClientLogs |
Enables client-side logging; LogLevel sets the level of detail. |
Connection information can also be provided through the local client.ncconf file.
Usage
After obtaining an ICache instance, use it to add, retrieve, update, and remove cached data.
using Alachisoft.NCache.Client;
using Alachisoft.NCache.Runtime.Caching;
ICache cache = CacheManager.GetCache("defaultCache");
var customer = new Customer
{
CustomerId = "ALFKI",
Name = "Alfreds Futterkiste"
};
string key = $"Customer:{customer.CustomerId}";
// Add data to the cache
cache.Add(key, customer);
// Retrieve data from the cache
Customer cachedCustomer = cache.Get<Customer>(key);
// Update data in the cache
customer.Name = "Updated Customer Name";
cache.Insert(key, customer);
// Remove data from the cache
cache.Remove(key);
Expiration and priority are configured through CacheItem.
var cacheItem = new CacheItem(customer)
{
Expiration = new Expiration(ExpirationType.Sliding, TimeSpan.FromMinutes(5)),
Priority = CacheItemPriority.High
};
cache.Insert(key, cacheItem);
Pub/Sub messaging and event notifications are available through ICache.MessagingService.
using Alachisoft.NCache.Runtime.Caching;
ITopic topic = cache.MessagingService.GetTopic("orderTopic")
?? cache.MessagingService.CreateTopic("orderTopic");
// Subscribe
ITopicSubscription subscription = topic.CreateSubscription(
(sender, args) => Console.WriteLine(args.Message.Payload));
// Publish
topic.Publish(new Message(customer), DeliveryOption.All);
Once connected:
- Cache operations are performed through the
ICacheinterface. - Expiration and priority can be configured through
CacheItem. - Messaging and event notifications are available through
IMessagingService.
Validation
When CacheManager.GetCache() is called, NCache validates the cache name and the supplied connection settings before establishing a cache connection.
The following conditions should be met:
- The cache name must be specified.
- The specified cache must already exist and be running.
CacheConnectionOptions, when provided, must contain valid connection settings.- Each entry in
ServerListmust specify a valid NCache server address. - The client machine must be able to communicate with the cache servers.
If the cache does not exist, cannot be reached, or the supplied connection information is invalid, NCache throws an exception while establishing the connection.
Best Practices
- Reuse the
ICacheinstance throughout the application instead of creating a new connection for every operation. - Configure multiple cache server addresses in
ServerListfor distributed deployments. - Use appropriate expiration policies to prevent unused data from remaining in the cache.
- Avoid caching excessively large objects.
- Use bulk operations where appropriate.
- Use separate cache configurations for development, testing, and production environments.
- Dispose of the cache connection when the application shuts down.
Resources
- NCache Documentation
- Alachisoft.NCache.Opensource.SDK
- NCache Open Source on GitHub
- Programmers Guide
- Alachisoft Website
Technical Support
NCache Open Source is provided free of cost and as-is, without commercial support.
- Report issues and ask questions on the NCache GitHub repository.
- For supported editions of NCache, visit the Alachisoft Support Center or contact support@alachisoft.com.
Copyrights
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 is compatible. 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. |
-
.NETFramework 4.6.2
- Newtonsoft.Json (>= 13.0.4)
-
.NETStandard 2.0
- Microsoft.Windows.Compatibility (>= 8.0.32)
- Newtonsoft.Json (>= 13.0.4)
- System.Data.Common (>= 4.3.0)
- System.IO.Pipelines (>= 8.0.0)
- System.Reflection.Emit (>= 4.7.0)
- System.Reflection.Emit.ILGeneration (>= 4.7.0)
- System.Reflection.Emit.Lightweight (>= 4.7.0)
- System.Reflection.TypeExtensions (>= 4.7.0)
- System.Runtime (>= 4.3.1)
- System.Runtime.Serialization.Primitives (>= 4.3.0)
- System.Text.RegularExpressions (>= 4.3.1)
- System.Xml.XmlSerializer (>= 4.3.0)
NuGet packages (21)
Showing the top 5 NuGet packages that depend on Alachisoft.NCache.Opensource.SDK:
| Package | Downloads |
|---|---|
|
NCache.Microsoft.Extensions.Caching.Opensource
Distributed cache implementation of Microsoft.Extensions.Caching.Distributed.IDistributedCache using NCache Opensource. This implementation of IDistributedCache can also be used for caching ASP.NET Core response. |
|
|
AspNet.SessionState.NCache.Opensource
This contains a custom ASP.NET session state provider using NCache Opensource. |
|
|
AspNetCore.Session.NCache.Opensource
This contains a custom ASP.NET Core session state middleware using NCache Opensource. |
|
|
NHibernate.NCache.Opensource
Caching provider for NHibernate using NCache Opensource. |
|
|
AspNet.SignalR.NCache.Opensource
A backplane using NCache Opensource messaging service for scaling out ASP.NET SignalR applications. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Alachisoft.NCache.Opensource.SDK:
| Repository | Stars |
|---|---|
|
Alachisoft/NCache
NCache: Highly Scalable In-Memory Distributed Cache for .NET
|