NCache implementation of CacheManager.Core cache handles and backplane, allowing CacheManager.Core to use an NCache cache as its distributed cache handle while leveraging NCache's Messaging Service as a backplane for cache synchronization across multiple application instances.
| Package | Version |
|---|---|
| Alachisoft.NCache.Opensource.SDK | >= 5.3.6.2 |
| CacheManager.Core | Compatible with CacheManager.Core |
| Microsoft.Extensions.Logging.Abstractions | Supported |
Install-Package NCache.OSS.CacheManager.Core
dotnet add package NCache.OSS.CacheManager.CoreBefore using this package, ensure you have:
- NCache Server – a running NCache cluster
- An NCache cache – created on the cluster, matching the
CacheNamespecified inNCacheOptions - A CacheManager.Core instance already configured in your application
The NCache CacheManager.Core integration provides both a distributed cache handle and a cache synchronization backplane for CacheManager.Core.
The package includes:
NCacheCacheHandle<T>— aBaseCacheHandleimplementation that stores cache entries in an NCache cacheNCacheCacheBackplane— a CacheManager backplane implementation that uses NCache's Messaging Service (Pub/Sub topics) to propagate cache invalidation events across multiple application instances
Cache connections are established through CacheManager.GetCache using the supplied NCacheOptions. When configured with a backplane, invalidation messages are published over an NCache topic, allowing all connected CacheManager instances to keep their local caches synchronized.
Key benefits:
- Native CacheManager.Core cache handle implementation backed by NCache
- Distributed cache synchronization using NCache Messaging Service
- Supports CacheManager CRUD operations
- Supports absolute and sliding expiration
- Configurable NCache connectivity through a single options class
- Drop-in integration with existing CacheManager.Core configuration
Limitations
- Tag-based eviction is not supported
- Some advanced functionality may be limited by the NCache Open Source edition
NCache integration is configured by passing an NCacheOptions instance when registering the cache handle and backplane.
var services = new ServiceCollection();
services.AddLogging(cfg =>
{
cfg.AddConsole();
cfg.SetMinimumLevel(LogLevel.Information);
});
var provider = services.BuildServiceProvider();
var loggerFactory = provider.GetRequiredService<ILoggerFactory>();
var options = new NCacheOptions
{
CacheName = "demoCache",
ServerList = new List<NCacheOptions.ServerConfig>
{
new NCacheOptions.ServerConfig
{
Ip = "127.0.0.1"
}
}
};
var cache = CacheFactory.Build<string>("myCache", settings =>
{
settings.WithDictionaryHandle();
settings.WithHandle(
typeof(NCacheCacheHandle<>),
"cache_handle_name",
true,
options);
settings.WithBackplane(
typeof(NCacheCacheBackplane),
"ncache_config_key",
"example_topic_name",
options);
},
loggerFactory);NCacheOptions controls how the integration connects to NCache.
| Property | Description |
|---|---|
CacheName |
Name of the NCache cache instance. The cache must already exist in the cluster. |
ServerList |
List of NCache server nodes used to establish the connection. |
ServerConfig.Ip |
IP address or hostname of an NCache server. |
ServerConfig.Port |
Server port. Defaults to 9800 if not specified. |
Register the NCache cache handle and backplane when configuring CacheManager.Core:
var cache = CacheFactory.Build<string>("myCache", settings =>
{
settings.WithDictionaryHandle();
settings.WithHandle(
typeof(NCacheCacheHandle<>),
"cache_handle_name",
true,
options);
settings.WithBackplane(
typeof(NCacheCacheBackplane),
"ncache_config_key",
"example_topic_name",
options);
},
loggerFactory);Once configured:
- CacheManager CRUD operations are executed against the configured NCache cache.
- Absolute and sliding expiration policies are enforced by NCache.
- Cache invalidation notifications are propagated through the NCache backplane, allowing multiple application instances to maintain synchronized local caches.
During initialization, the integration validates the supplied configuration before establishing a connection.
The following checks are performed:
NCacheOptionsmust not benullCacheNamemust be specified- Every
ServerListentry must contain a valid IP address - Port values, when specified, must be within the range
1–65535
After validation, a cache connection is established using:
CacheManager.GetCache(CacheName, CacheConnectionOptions)If validation fails or the cache cannot be reached, an exception is thrown during initialization.
- Create the NCache cache before starting your application.
- Configure
ServerListfor distributed deployments. - Avoid caching excessively large objects.
- Use a dedicated NCache cluster for each environment.
- Configure the backplane when multiple application instances share the same cache.
Demonstrates configuring CacheManager.Core to use NCache as a distributed cache handle and backplane. The sample shows how to configure NCacheCacheHandle and NCacheCacheBackplane, then perform common cache operations including CRUD operations, region-based caching, expiration, and cache synchronization.
Follow the following instructions to run the sample.
dotnet restore
dotnet runThe sample performs the following operations automatically:
- Configures CacheManager with an in-memory dictionary handle, an NCache distributed cache handle, and an NCache backplane.
- Adds an item with an absolute expiration.
- Retrieves the cached item.
- Checks whether the cached item exists.
- Removes the cached item.
- Adds multiple items to a cache region.
- Retrieves an item from the region.
- Checks whether the regional item exists.
- Clears the entire cache region.
Observe the console output to verify that each operation completes successfully and that cache operations are synchronized through the configured NCache backplane.
- NCache Documentation
- CacheManager.Core
- NuGet Package NCache.OSS.CacheManager.Core
- NCache CacheManager.Core Documentation
- NCache Open Source
- Alachisoft Website
Alachisoft © provides various sources of technical support.
- Please refer to http://www.alachisoft.com/support.html to select a support resource suitable for your issue.
- To request additional features in the future, or if you notice any discrepancy regarding this document, please drop an email to support@alachisoft.com.
Copyright © 2026 Alachisoft. All rights reserved.