Client Application Configuration Reference
NCache client applications use the ncache section of appsettings.json or app.config/web.config to identify the cache and provide the connection information required to reach it. For a remote cache, this includes the server endpoints, port, and applicable authentication and TLS settings. After connecting, the client obtains the remaining client behavior settings from the cache server, as described in Client Configuration.
This reference explains the application configuration structure and each supported setting for the client configuration model. The JSON properties and XML attributes use the same setting names and values; their parent sections differ as shown below. For practical JSON and XML examples covering load balancers, LDAP and TLS, gMSA, and in-process local caches, see Client Configuration Examples.
Client Application Configuration Syntax
The following syntax follows the configuration template displayed by the NCache Management Center. Each setting contains one configuration value. Comments identify required and optional settings, list supported alternatives, and show default values. Replace the sample server addresses with the endpoints for your cache; select one supported value for endpointType and security, and separate multiple server endpoints with commas. Empty credential and certificate values are treated as unset, corresponding to the null default shown in the comments.
appsettings.json Syntax
Add ncache to the root object of the application's appsettings.json. Each child object is named after the cache to which the application connects. The inline comments are supported by the NCache client configuration reader.
{
"ncache": {
"defaultCache": {
"endpointType": "server", // optional. (server, load-balancer) default: server
"server": "20.200.20.11,20.200.20.12", // required. (server IP address/domain, load balancer IP address/domain)
"port": 9800, // optional. default: 9800
"tlsCertPath": "", // optional. default: null
"tlsCertPassword": "", // optional. default: null - password of the private key in tlsCertPath, when it is encrypted
"security": "ldap", // optional. (ldap, gmsa-ldap) default: ldap
"userId": "", // optional. default: null
"password": "" // optional. default: null
}
}
}
Understanding the Client Application Configuration Tags
Select the configuration file used by your application to view its structure and supported settings.
ncache
The ncache object is a property of the root JSON object. It contains one child object for each cache used by the application.
Cache Object
Name each child object after the cache requested by the application, for example defaultCache. The name is case-insensitive. defaultCache is an example name and does not select a default cache automatically. Place the connection properties inside this object.
{
"ncache": {
"defaultCache": {
"server": "20.200.20.11",
"port": 9800
}
}
}
cacheName: In the cache-name-keyed format shown above, the object key identifies the cache and a separate
cacheNameproperty is unnecessary. The reader also supports a flatncacheobject withcacheName, or acachesarray whose entries each containcacheName.endpointType: Specifies whether the endpoints identify cache servers directly or a load balancer. Supported values are
serverandload-balancer; the default isserver. Useserverfor IP addresses and DNS names of cache servers. Useload-balancerwhenservercontains the load balancer address. DNS is resolved from the hostname and does not require a separate endpoint type. This setting describes the configured endpoints; it does not configure a load balancer or change the server-managed client load-balancing setting.server: Specifies the cache server IP addresses or DNS names, or the load balancer address, used to establish the initial connection. Provide at least one endpoint for a remote cache unless the application supplies a server list programmatically. There is no configured endpoint by default. Separate multiple endpoints with commas, for example
20.200.20.11,20.200.20.12, and usencache.corp.localfor a DNS endpoint. You can include a port after an address, for example20.200.20.11:9800. If an address has no port, NCache uses theportsetting from this cache entry, or9800when that setting is omitted.port: Specifies the port used to connect to the addresses listed in
server. The default is9800; a configured value must be a whole number from1to65535and match the port exposed by the server or load balancer. For example, ifservercontains20.200.20.11,20.200.20.12:9900andportis9800, NCache connects to20.200.20.11on port9800and to20.200.20.12on port9900. A port included directly in an address applies to that address.tlsCertPath: Specifies the path to the client certificate and its private key for mutual TLS authentication. The default is unset. Use a PEM file for modern .NET clients. .NET Framework clients support only PFX certificates. The application account must be able to access the certificate and private key. Use a path on the client machine, and escape backslashes in JSON, for example
C:\\certs\\client.pem. Configuring this path does not enable TLS on the server; configure TLS and certificate trust as described in the linked TLS setup instructions.tlsCertPassword: Specifies the password used to decrypt the certificate's encrypted private key or password-protected PFX file referenced by
tlsCertPath. The default is unset. Omit this setting when the certificate's private key does not require a password. This value is separate from the cache user'spassword.security: Selects the client authentication mode. Supported values are
ldapandgmsa-ldap; the default isldap. Withldap, the client uses the supplieduserIdandpasswordwhen authentication is required. Withgmsa-ldap, the client uses the application's process identity and ignoresuserIdandpassword. Configure the account, application identity, and server authorization as described in Configure Group Managed Service Account (gMSA). Selecting a mode does not enable server-side security or grant access to the cache.userId: Specifies the authorized user's identity for LDAP authentication. The default is unset. Supply the identity accepted by the configured directory and NCache security settings. This setting is ignored when
securityisgmsa-ldap.password: Specifies the LDAP user's password. The default is unset. Supply the user's actual password when LDAP authentication is required; this setting is ignored when
securityisgmsa-ldap. Do not use a certificate password in this field.inproc: Specifies whether the entry describes a standalone in-process local cache hosted by the application. Supported values are
trueandfalse; the default isfalse. Whentrue, omit all remote connection settings, includingserver,port,endpointType, certificate settings,security, and credentials. This setting describes a local cache, rather than an in-process Client Cache in front of a remote cache.size: Specifies the storage size of an in-process local cache in megabytes. It accepts a positive whole number, for example
1024; the default is1024MB when omitted. Use this setting only withinprocset totrue. A remote cache's storage size is configured on the server.
Note
Use the canonical camelCase names shown in this reference. Setting-name matching ignores case, hyphens, and underscores, but unknown settings and duplicate normalized settings on a cache entry cause configuration errors. Empty or null scalar values are treated as unset. For an in-process cache, remove remote connection properties entirely, even if their values are empty.
Configuration File Selection and Precedence
NCache reads appsettings.json from the application's base directory, falling back to the current working directory if the base directory does not contain that file. Ensure the file is included in the deployed application.
If DOTNET_ENVIRONMENT is set, NCache also reads appsettings.{environment}.json from the same directory. If it is not set, NCache uses ASPNETCORE_ENVIRONMENT instead. Settings in the environment-specific entry override matching properties of the base entry. Keep the base appsettings.json file present so NCache can locate this directory.
For a requested cache, the merged JSON entry takes precedence over the XML entry. NCache consults the application's XML configuration only when no matching JSON entry exists; it does not fill missing JSON properties from XML. Explicitly supplied connection options take precedence over the corresponding application configuration settings. For programmatic configuration, see Connect to Cache.
Note
Connection retries, request timeouts, client logging, and Client Cache behavior are supplied by the cache server. Do not copy these server-managed settings into the cache entry in the application configuration. Refer to Cache Config (config.ncconf) for the server-side configuration reference.
See Also
Client Configuration
Cache Config (config.ncconf)
Test Client-Server Connectivity
Configure TLS Security