Client Configuration
NCache uses a thin-client configuration model in which client applications do not require a local NCache configuration file. Instead, the application provides only the information required to establish a connection with the cache. You can copy a configuration template from the NCache Management Center and replace the sample values with the connection information for your application.
Using the NCache Management Center
You can view and copy the application-side configuration template from the details page of a clustered cache.
Launch the NCache Management Center by browsing to http://localhost:9801 or
<server-ip>:9801.In the left navigation bar, click Clustered Caches. Open the details page of the cache to which your application will connect.
In the Server Nodes toolbar, click Client Configuration. This opens the Client Configuration dialog.
Under Configuration file, select appsettings.json or app.config / web.config. The dialog displays the template for the selected file type. Each setting contains one configuration value; comments list the available alternatives, whether the setting is required or optional, and its default value where applicable.
Click Copy and paste the ncache section inside the root object of appsettings.json, alongside the application's other properties.
The JSON template uses inline comments beside each setting. For example, endpointType is set to server, while its comment lists server and load-balancer as the supported choices. Similarly, security is set to ldap, with gmsa-ldap listed as an alternative in the comment.

- Replace the sample server endpoints with your cache server or load balancer addresses, and select the
endpointTypeandsecurityvalues for your deployment. Supply the port, user credentials, and client certificate settings where required. The displayed server addresses are examples; they must be replaced with your own endpoints. Leave optional certificate and credential values empty or omit them when they are not required.
Note
For JSON and XML syntax with comments, see Client Application Configuration Syntax.
After the application establishes its initial connection, NCache retrieves the remaining client behavior settings from the cache server. These settings are maintained centrally with the cache configuration rather than on individual client machines. When these settings are changed on the server, client applications obtain the applicable configuration from the server.
Note
For configuration syntax, supported settings, and defaults, see Client Application Configuration Reference.
Note
Learn how to connect to cache using the NCache API in the Developer's Guide.
Configuration Examples
The following examples show how to configure common application connection scenarios. Each setting uses one value, with supported choices and default values described in comments. A setting marked optional may still be needed for the authentication or TLS requirements of the selected deployment. Select the file tab for your application to view the configuration and its placement instructions.
Connect Through a Load Balancer
Set endpointType to load-balancer and provide the address and exposed port of your load balancer. The following JSON and XML entries describe the same connection.
Add the ncache object to the root object of appsettings.json. See the JSON configuration settings for the purpose and defaults of each property.
{
"ncache": {
"defaultCache": {
"endpointType": "load-balancer", // optional. (server, load-balancer) default: server
"server": "20.200.20.13", // required. (server IP address/domain, load balancer IP address/domain)
"port": 9800 // optional. default: 9800
}
}
}
Use LDAP Authentication and a Client Certificate
The following entries configure a DNS endpoint, LDAP credentials, and a client certificate for a deployment that requires mutual TLS. Replace the sample identity, passwords, and certificate path with values for your application. Use a PEM certificate for modern .NET clients and a PFX certificate for .NET Framework clients.
Add the ncache object to the root object of appsettings.json. See the JSON configuration settings for the purpose and defaults of each property.
This example uses a PEM certificate for a modern .NET client.
{
"ncache": {
"defaultCache": {
"server": "ncache.corp.local", // required. (server IP address/domain, load balancer IP address/domain)
"security": "ldap", // optional. (ldap, gmsa-ldap) default: ldap
"userId": "john_smith", // optional. default: null; required for this LDAP authentication example
"password": "<user-password>", // optional. default: null; required for this LDAP authentication example
"tlsCertPath": "C:\\certs\\client.pem", // optional. default: null; required for this mutual TLS example
"tlsCertPassword": "<certificate-password>" // optional. default: null; supply only if the private key is encrypted
}
}
}
Use the Application's gMSA Identity
Run the application under the authorized gMSA identity and select gmsa-ldap. Omit user credentials because authentication uses the process identity.
Add the ncache object to the root object of appsettings.json. See the JSON configuration settings for the purpose and defaults of each property.
{
"ncache": {
"defaultCache": {
"server": "20.200.20.11,20.200.20.12", // required. (server IP address/domain, load balancer IP address/domain)
"security": "gmsa-ldap" // optional. (ldap, gmsa-ldap) default: ldap
}
}
}
Configure an In-Process Local Cache
The following entries configure a standalone local cache with 1024 MB of storage. No server endpoints or remote authentication settings are required.
Add the ncache object to the root object of appsettings.json. See the JSON configuration settings for the purpose and defaults of each property.
{
"ncache": {
"defaultCache": {
"inproc": true, // optional. (true, false) default: false
"size": 1024 // optional. default: 1024 MB; applies only when inproc is true
}
}
}
Additional Application Settings
The dedicated <ncache> section contains the cache connection settings described in the Client Application Configuration Reference. The application-wide settings PreferredServerReconnectDelay and UseSyncMessageDeliveryMode continue to be read from <appSettings> in app.config/web.config. Keep this section alongside <ncache> inside <configuration>.
<appSettings>
<!-- Optional. Default: 60 seconds. Values are limited to 10 through 300 seconds. -->
<add key="PreferredServerReconnectDelay" value="10" />
<!-- Optional. (true, false) Default: false. Use true for synchronous message notifications. -->
<add key="UseSyncMessageDeliveryMode" value="true" />
</appSettings>
- PreferredServerReconnectDelay specifies the delay, in seconds, before the client attempts to rebalance to its preferred server. The default is
60seconds. Supply a whole number of seconds. Values below10take effect as10seconds, and values above300take effect as300seconds. For example, a configured value of3takes effect as10seconds. - UseSyncMessageDeliveryMode accepts
trueorfalseand defaults tofalse. It selects synchronous message notification delivery when set totrue. When omitted or set tofalse, message notifications use asynchronous delivery unlessUseThreadPoolForMessageInvocationis enabled, which also selects the synchronous notification path.
Important
These settings are not supported as attributes on a cache entry under <ncache><caches> or as properties of a cache entry in the JSON ncache section. Adding them there causes an unknown-setting configuration error. Retain them in <appSettings> when using these options.
See Also
Connect to Cache
NCache Client
Client Application Configuration Reference
Client Management
