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

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.

    An image of the Clustered Caches tab in the NCache Management Center showing a stopped Partition-Replica Distributed Cache called defaultCache.

  • 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.

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

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.

Client Configuration dialog showing the appsettings.json template with one value per setting and inline comments for supported choices, required settings, and defaults.

Click Copy and paste the section registration and <ncache> section inside <configuration> in app.config/web.config. If <configSections> already exists, merge the ncache registration into it. Keep <configSections> as the first child of <configuration>.

The XML template places the same guidance in a comment above the cache entry. The <add> element contains one value for each attribute, including the optional tlsCertPassword attribute for an encrypted client certificate private key.

Client Configuration dialog showing the app.config or web.config template with XML comments describing the settings and their defaults.

  • Replace the sample server endpoints with your cache server or load balancer addresses, and select the endpointType and security values 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.

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

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

Place <ncache> inside <configuration> in app.config/web.config and retain the section registration shown in the XML configuration syntax. See the XML configuration settings for attribute descriptions.

<ncache>
  <caches>
    <!-- endpointType: optional. (server, load-balancer) default: server
         server: required. (server IP address/domain, load balancer IP address/domain)
         port: optional. default: 9800 -->
    <add name="defaultCache" endpointType="load-balancer"
         server="20.200.20.13" port="9800" />
  </caches>
</ncache>

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.

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

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

Place <ncache> inside <configuration> in app.config/web.config and retain the section registration shown in the XML configuration syntax. See the XML configuration settings for attribute descriptions.

This example uses a PFX certificate for a .NET Framework client. For a modern .NET client using XML configuration, supply a PEM path instead.

<ncache>
  <caches>
    <!-- server: required. (server IP address/domain, load balancer IP address/domain)
         security: optional. (ldap, gmsa-ldap) default: ldap
         userId: optional. default: null; required for this LDAP authentication example
         password: optional. default: null; required for this LDAP authentication example
         tlsCertPath: optional. default: null; required for this mutual TLS example
         tlsCertPassword: optional. default: null; supply only if the private key is encrypted -->
    <add name="defaultCache" server="ncache.corp.local"
         security="ldap" userId="john_smith" password="USER_PASSWORD"
         tlsCertPath="C:\certs\client.pfx" tlsCertPassword="CERTIFICATE_PASSWORD" />
  </caches>
</ncache>

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.

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

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

Place <ncache> inside <configuration> in app.config/web.config and retain the section registration shown in the XML configuration syntax. See the XML configuration settings for attribute descriptions.

<ncache>
  <caches>
    <!-- server: required. (server IP address/domain, load balancer IP address/domain)
         security: optional. (ldap, gmsa-ldap) default: ldap -->
    <add name="defaultCache" server="20.200.20.11,20.200.20.12"
         security="gmsa-ldap" />
  </caches>
</ncache>

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.

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

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

Place <ncache> inside <configuration> in app.config/web.config and retain the section registration shown in the XML configuration syntax. See the XML configuration settings for attribute descriptions.

<ncache>
  <caches>
    <!-- inproc: optional. (true, false) default: false
         size: optional. default: 1024 MB; applies only when inproc is true -->
    <add name="defaultCache" inproc="true" size="1024" />
  </caches>
</ncache>

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 60 seconds. Supply a whole number of seconds. Values below 10 take effect as 10 seconds, and values above 300 take effect as 300 seconds. For example, a configured value of 3 takes effect as 10 seconds.
  • UseSyncMessageDeliveryMode accepts true or false and defaults to false. It selects synchronous message notification delivery when set to true. When omitted or set to false, message notifications use asynchronous delivery unless UseThreadPoolForMessageInvocation is 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

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