Create Client Cache with NuGet Package Installation
NCache allows applications using NCache NuGet packages to use an InProc Client Cache without requiring an NCache Client installation on the client machine. The Client Cache configuration is maintained with the clustered cache and is automatically provided to connecting client applications.
When the application connects to the clustered cache, the configured InProc Client Cache becomes available within the application process. This allows frequently accessed data to be served locally while the Client Cache remains synchronized with the clustered cache.
Note
An OutProc Client Cache requires NCache Client to be installed on the client node. Therefore, when using NCache NuGet packages without an NCache Client installation, configure the Client Cache as InProc.
Prerequisites
Before using a Client Cache with a NuGet-based client application, ensure that:
The required NCache NuGet package is installed in the client application.
The clustered cache is created and running.
An InProc Client Cache is configured and enabled for the clustered cache.
Configure Client Cache
The Client Cache configuration is maintained with the clustered cache. You do not need to create or maintain a separate Client Cache configuration on the client machine.
Configure an InProc Client Cache for the clustered cache using the NCache Management Center or PowerShell. Depending on your requirements, you can configure either a Regular or Full-Data Client Cache.
When configuring the Client Cache, select InProc as its isolation level. The Client Cache name is automatically derived from the clustered cache name. For example, the Client Cache configured for defaultCache is named defaultCache_cc.
Configure the Client Application
The client application must provide the information required to connect to the clustered cache, including the cache name and server endpoint. You can provide the server information through the application's configuration or programmatically through CacheConnectionOptions.
The following example connects to defaultCache running on server 20.200.20.11:
using Alachisoft.NCache.Client;
string cacheName = "defaultCache";
var connectionOptions = new CacheConnectionOptions();
connectionOptions.ServerList.Add(
new ServerInfo("20.200.20.11", 9800));
using ICache cache =
CacheManager.GetCache(cacheName, connectionOptions);
When the application connects, NCache obtains the Client Cache configuration associated with the clustered cache. If Client Cache is enabled, the configured InProc Client Cache becomes active within the application process and is used for applicable cache operations.
Note
Client Cache settings such as its type, size, isolation level, eviction behavior, polling interval, and Full-Data settings are maintained with the clustered cache and do not need to be duplicated in a client-side NCache configuration file.
The application can then perform cache operations normally. The Client Cache remains synchronized with the clustered cache and serves applicable operations locally.
Note
Enabling or disabling the Client Cache is applied to connected clients at runtime. Disabling the Client Cache stops it on connected clients while retaining its configuration. The application remains connected to the clustered cache and continues cache operations directly against it. Re-enabling the Client Cache allows connected applications that previously initialized it to resume using it without reconnecting. Applications connected before Client Cache was configured must restart to initialize it.
See Also
Client Cache Architecture
Client Configuration
Create Regular Client Cache
Create Full-Data Client Cache
Remove Client Cache