• Facebook
  • Twitter
  • Youtube
  • LinkedIn
  • RSS
  • Docs
  • Comparisons
  • Blogs
  • Try NCache
  • Contact Us
Try NCache
Show / Hide Table of Contents

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
  • app.config / web.config

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
    }
  }
}

app.config / web.config Syntax

Register the ncache section inside <configSections>, which must be the first child of <configuration>. Add the cache entries under <ncache><caches>. For an executable application, deploy the application configuration as its corresponding .exe.config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="ncache"
             type="Alachisoft.NCache.Client.NCacheSection, Alachisoft.NCache.Client" />
  </configSections>
  <ncache>
    <caches>
      <!-- endpointType: optional. (server, load-balancer) default: server
           server: required. (server IP address/domain, load balancer IP address/domain)
           port: optional. default: 9800
           tlsCertPath: optional. default: null
           tlsCertPassword: optional. default: null - password of the private key in tlsCertPath, when it is encrypted
           security: optional. (ldap, gmsa-ldap) default: ldap
           userId: optional. default: null
           password: optional. default: null -->
      <add name="defaultCache"
           endpointType="server"
           server="20.200.20.11,20.200.20.12"
           port="9800"
           tlsCertPath=""
           tlsCertPassword=""
           security="ldap"
           userId=""
           password="" />
    </caches>
  </ncache>
</configuration>
Note

If the application already registers ncache through an NCache Session State or Output Cache provider, retain that registration and add <caches> alongside the existing provider settings. Do not register the same section twice.

Understanding the Client Application Configuration Tags

Select the configuration file used by your application to view its structure and supported settings.

  • appsettings.json
  • app.config / web.config

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 cacheName property is unnecessary. The reader also supports a flat ncache object with cacheName, or a caches array whose entries each contain cacheName.

  • endpointType: Specifies whether the endpoints identify cache servers directly or a load balancer. Supported values are server and load-balancer; the default is server. Use server for IP addresses and DNS names of cache servers. Use load-balancer when server contains 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 use ncache.corp.local for a DNS endpoint. You can include a port after an address, for example 20.200.20.11:9800. If an address has no port, NCache uses the port setting from this cache entry, or 9800 when that setting is omitted.

  • port: Specifies the port used to connect to the addresses listed in server. The default is 9800; a configured value must be a whole number from 1 to 65535 and match the port exposed by the server or load balancer. For example, if server contains 20.200.20.11,20.200.20.12:9900 and port is 9800, NCache connects to 20.200.20.11 on port 9800 and to 20.200.20.12 on port 9900. 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's password.

  • security: Selects the client authentication mode. Supported values are ldap and gmsa-ldap; the default is ldap. With ldap, the client uses the supplied userId and password when authentication is required. With gmsa-ldap, the client uses the application's process identity and ignores userId and password. 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 security is gmsa-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 security is gmsa-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 true and false; the default is false. When true, omit all remote connection settings, including server, 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 is 1024 MB when omitted. Use this setting only with inproc set to true. 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>

This is the root element of the application configuration file. It contains the section registrations and the <ncache> section.

<configSections> / <section>

Place <configSections> first inside <configuration>. Register the ncache section with a <section> element whose name is ncache and whose type is Alachisoft.NCache.Client.NCacheSection, Alachisoft.NCache.Client. Merge this registration into an existing <configSections> element when one is already present.

<ncache>

This element contains the application's NCache configuration, including the <caches> collection.

<caches>

This collection contains one <add> element for each cache used by the application.

<add>

Each <add> element identifies a cache and specifies its connection settings as attributes.

<add name="defaultCache" server="20.200.20.11" port="9800" />
  • name: Specifies the cache requested by the application. Each <add> element requires a nonempty, unique name. Cache-name matching is case-insensitive. defaultCache is an example name and does not select a default cache automatically.

  • endpointType: Specifies whether the endpoints identify cache servers directly or a load balancer. Supported values are server and load-balancer; the default is server. Use server for IP addresses and DNS names of cache servers. Use load-balancer when server contains 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 use ncache.corp.local for a DNS endpoint. You can include a port after an address, for example 20.200.20.11:9800. If an address has no port, NCache uses the port setting from this cache entry, or 9800 when that setting is omitted.

  • port: Specifies the port used to connect to the addresses listed in server. The default is 9800; a configured value must be a whole number from 1 to 65535 and match the port exposed by the server or load balancer. For example, if server contains 20.200.20.11,20.200.20.12:9900 and port is 9800, NCache connects to 20.200.20.11 on port 9800 and to 20.200.20.12 on port 9900. 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 specify the PFX path for a .NET Framework client, for example C:\certs\client.pfx. For a modern .NET client using XML configuration, specify a PEM file. 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's password.

  • security: Selects the client authentication mode. Supported values are ldap and gmsa-ldap; the default is ldap. With ldap, the client uses the supplied userId and password when authentication is required. With gmsa-ldap, the client uses the application's process identity and ignores userId and password. 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 security is gmsa-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 security is gmsa-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 true and false; the default is false. When true, omit all remote connection settings, including server, 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 is 1024 MB when omitted. Use this setting only with inproc set to true. 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.

Note

Application-wide settings such as PreferredServerReconnectDelay and UseSyncMessageDeliveryMode remain in <appSettings> inside <configuration>. See Additional Application Settings for their usage and effective values.

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

Contact Us

PHONE

+1 214-619-2601   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Try NCache
Pricing
NCache Playground

Deployments
  • Cloud
  • Docker
  • Kubernetes
  • On-Premises
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • SignalR Backplane
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Blogs
  • Foundations
  • Videos
  • Comparisons
  • Shows
  • Whitepapers
  • Articles
  • Tech Talks
  • Magazine Articles
  • Third-Party Articles
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Docs
  • Schedule a Demo
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Terms of Use
  •  
  • Privacy Policy
  •  
  • Cookie Policy
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
  • Facebook
  • Twitter
  • Youtube
  • LinkedIn
  • RSS