• Products
  • Solutions
  • Customers
  • Resources
  • Company
  • Pricing
  • Download
Try Playground
  • Configure Client Cache
  • Create Client Cache with NuGet
Show / Hide Table of Contents
  • Administrator's Guide
  • NCache Architecture
    • Cache Topologies
      • Partitioned Topologies
      • Replicated Topology
      • Mirrored Topology
      • Scalability in Topologies
    • Dynamic Clustering
    • Local Cache
    • Cache Client
    • Client Cache
    • Bridge for WAN Replication
    • Connectivity with Load Balancer
    • Serialization Format
    • Data Encryption
    • Data Compression
    • Data Load Balancing
    • Pipelining
    • Cache Server Backward Compatibility
    • Client Backward Compatibility
    • Eviction
    • Indexing
    • Split-Brain
    • Maintenance Mode
    • Runtime Data Sharing
    • Portable Data Types
    • Class Versioning
    • IP Binding with Multiple NICs
    • Graceful Node Down
    • Separate Cache Host Process
    • Self Healing Dynamic Clustering
    • Distributed Cache with Persistence
  • NCache Management Center
  • Configure Caches
    • Create a Cache
      • Local Cache Overview
        • Local Cache
        • Local Cache with Persistence
        • Pub/Sub Messaging Cache
        • Add Existing Cache
      • Clustered Cache Overview
        • Distributed Cache
        • Persistent Distributed Cache
        • Pub/Sub Messaging Cache
        • Add Existing Clustered Cache
        • Troubleshooting
    • Remove Cache
    • Clear Cache
    • Add Server Node
    • Remove Server Node
    • Add Test Data
    • Configure Query Indexes
    • Configure JSON Query Indexes
    • Compact Serialization
      • Non-Generic Registration
      • Non-Generic Unregistration
      • Generic Registration
      • Using Type Handler
    • Deploy Providers
    • Configure Custom Dependency
    • Add Data Source Providers
      • Read-Through Provider
      • Write-Through Provider
      • Write-Behind Provider
    • Loader and Refresher
    • Configure Maintenance Mode
      • Stop for Maintenance Mode
      • Exit Maintenance Mode
    • Configure LINQPad
      • Configure LinqPad for NCache
      • Querying Data in LinqPad
  • Configure Clients
    • Add Client Node
    • Remove Client Node
  • Configure Client Cache
    • Create Client Cache
    • Create Client Cache with NuGet
    • Enable Client Cache on Client Nodes
    • Disable Client Cache on Client Nodes
    • Remove Client Cache
  • Management Operations
    • Start Cache
    • Stop Cache
    • Restart Cache
    • Manage Cache Service on a Server Node
    • Memory Dumps
    • Data Load Balancing
    • Invoke Refresher Dataset
    • Import/Export Cache Data
    • Import Lucene Indexes
    • Suspend/Resume NCache Data Persistence
    • Backup and Restore NCache Persisted Data
  • Cache Settings
    • General Cache Settings
      • Cache Size
      • Cache Isolation Levels
      • Cache Serialization Format
      • Cache Data Expiration
    • Cache Cluster Settings
      • Ports
      • Operation Timeout
      • Configure Pipelining
      • Static Replication Interval
      • Connection Retries
      • Retry Interval
      • Split-Brain Auto Recovery
    • NCache Persistence Settings
      • Store Information
      • Persistence Interval
    • Error Logging
    • Cache Level Events
    • Client Activity Events
    • Eviction Policy
    • MapReduce
    • Register Classes for Portable Data Sharing
    • Compression
    • Email Notifications
    • Bind IP with Multiple NICs
      • Bind Cluster with a Dedicated IP
      • Bind Client/Server with a Dedicated IP
    • Heartbeat
    • Keep Alive
    • Client Death Detection
    • Communication Reliability
    • Auto Start Cache on Boot
    • Nagle's Algorithm
    • Dual Socket
    • Configuration Files
      • Client Side Configurations
        • Client Config
        • EFCaching Config
      • Server Side Configurations
        • Cache Config
        • Bridge Config
        • Modules Config
        • Security Config
        • TLS Config
        • Monitoring Config
        • Emails Template
  • Cache Server Settings
    • Server Connectivity
    • Bind to Multiple NICs
    • Server Ports
    • Memory
    • Custom Dependency
    • Request Inquiry
    • Windows Events
    • Message Events
    • Expiration & Eviction
    • SQL Server
    • Logging
    • Monitoring
    • Persistence Data Loading Retries
    • Miscellaneous Configurations
  • Bridge Server Settings
  • Cache Client Settings
  • Client Cache Settings
  • Configure Security
    • Configure Authentication and Authorization
    • Configure Encryption for Cache
    • Configure TLS Encryption
    • Configure HTTPS for NCache Management Center
  • Configure Bridge for WAN Replication
    • Create Bridge
    • Add Clustered Caches to Bridge
    • Configure Bridge Settings
    • Change Cache Synchronization Modes
    • Bridge Management
    • Synchronize Caches in Bridge
    • Leave Bridge
    • Remove Cache from Bridge
    • Configure Conflict Resolver
  • Setup Database for Cache Synchronization
    • Setup SQL Server Environment
    • Setup Oracle Database Environment
    • Setup OleDb Environment
    • Setup SQL Server for CLR Procedures
  • Simulate NCache Usage
  • Monitor Caches
    • Counters
      • Distributed Cache Counters
      • Distributed Cache with Persistence Counters
      • Pub/Sub Messaging Cache Counters
      • Distributed Lucene Cache Counters
      • Cache Client Counters
      • Bridge Counters
    • Monitor NCache using the NCache Management Center
      • Using Tabular Statistics
        • Configure Counters to Display Caching Statistics
        • Configure Counters to Display Pub/Sub Statistics
        • Configure Counters to Display Lucene Statistics
        • Configure Counters to Display Bridge Statistics
        • Browse Cache Statistics
        • Monitor Bridge
      • Using Monitoring Dashboards
        • Configure Monitor Settings
        • Configure Event Logging
        • Configure API Logging
        • Monitor with a Built-In NCache Monitor Dashboard
        • Monitor with the NCache Monitor Custom Dashboard
        • Monitor Cluster Connectivity
        • Monitor Cache Clusters using NCache Email Alerts
    • Monitor Cache Using Command Line Tools
      • Monitor Cache Server Statistics with Command Line Tools
      • Monitor Cache Client Statistics with Command Line Tools
    • Monitor NCache Using Windows PerfMon Tool
      • Monitoring Cache Server Counters using PerfMon
      • Monitoring Cache Client Counters using PerfMon
      • Monitor Bridge Counters Using PerfMon Tool
    • Monitor NCache using Prometheus
    • Monitor NCache using Grafana
    • Monitor NCache Using SNMP Counters
    • Monitor NCache Using JMX Counters
    • Logging
      • NCache Log Viewer
      • Performance Counters Logging
      • Windows Event Logging
      • Cache Health Alerts
      • Email Notifications on NCache Events
      • Cache Server Logging
      • Client Side API Logging
      • Cache Event IDs
      • Feature Usage Logging
    • Troubleshooting NCache Monitoring
      • Computer Name Not Found
      • Diskperf Not Installed
      • No READ Access to Perflib Subkeys
      • Unable to Connect to Remote Server
    • IPV6 Support

Create Client Cache with NuGet Packages Installation

If you're using NCache NuGet packages and want to create a Client Cache using your application without having NCache installed, then NCache allows you to do so in the following steps:

Prerequisites for Creating Client Cache

The required NuGet package must be already installed in your application. On successful installation of the NuGet package, it copies these two configuration files in your application's local directory:

  • config.ncconf: It is used for local InProc cache and InProc Client Caches. For the Client Cache, the config.ncconf file must also contain the name of the clustered cache that this Client Cache is a part of.
  • client.ncconf: It contains information about the cache servers of each cache that the application needs to access.

Step 1: Edit NCache Configuration File

  • Open the configurations copied from the config.ncconf file. The configuration file comes with a default local cache by the name of mycache.
  • If you already have the configuration of the Client Cache, add the configuration under the <configuration> tag.
  • If you do not have the configuration of the Client Cache, copy the following configuration and paste it under the <configuration> tag.
Note

Ensure that you are using the JSON Serialization format for .NET 8.0, as BinaryFormatter Serialization methods are obsolete and prohibited in .NET 8.0. However, if you still want to use Binary Serialization, you can suppress the BinaryFormatter, as discussed here.

Regular Client Cache

Following is the configuration for the Regular Client Cache.

  <cache-config cache-name="demoClientCache" store-type="distributed-cache" environment="" config-id="4b121daa-7d50-49dc-9b68-c67889eaa084" config-version="0">
    <cache-settings inproc="False" last-modified="" auto-start="False" data-format="Serialized" serialization="Binary">
      <logging enable-logs="True" trace-errors="True" trace-notices="False" trace-warnings="False" trace-debug="False" log-path=""/>
      <performance-counters enable-counters="True" snmp-port="0"/>
      <data-load-balancing enabled="False" auto-balancing-threshold="60%" auto-balancing-interval="30sec"/>
      <compression enable-compression="False" threshold="100kb"/>
      <client-death-detection/>
      <client-activity-notification enabled="False" retention-period="5sec"/>
      <cache-notifications item-remove="False" item-add="False" item-update="False" expiration-time="15sec"/>
      <cleanup interval="15sec"/>
      <storage type="heap" cache-size="1024mb"/>
      <eviction-policy enabled-eviction="True" default-priority="normal" policy="lru" eviction-ratio="5%"/>
      <expiration-policy enabled="False">
        <absolute-expiration longer-enabled="False" longer-value="0" default-enabled="False" default-value="0"/>
        <sliding-expiration longer-enabled="False" longer-value="0" default-enabled="False" default-value="0"/>
      </expiration-policy>
      <sql-dependency use-default="True"/>
      <synchronization strategy="polling" polling-interval="10sec"/>
      <cache-topology topology="client-cache"/>
      <client-cache-settings server-cache="demoCache" type="regular" persist-queue="False" enable-disconnected="False" offline-queue-size="0"/>
      <tasks-config max-tasks="10" chunk-size="100" communicate-stats="False" queue-size="10" max-avoidable-exceptions="10"/>
      <split-brain-recovery enable="False" detection-interval="60"/>
    </cache-settings>
  </cache-config>

Full Data Client Cache

Important

If you make any configuration changes to the Full-Data Client Cache, you must restart the Client Cache.

Following is the configuration for the Full-Data Client Cache.

  <cache-config cache-name="demoClientCache" store-type="distributed-cache" environment="" config-id="8898e176-baac-4d06-bb2d-0499eadf397f" config-version="0">
    <cache-settings inproc="True" last-modified="" auto-start="False" data-format="Object" serialization="Binary">
      <logging enable-logs="True" trace-errors="True" trace-notices="False" trace-warnings="False" trace-debug="False" log-path=""/>
      <performance-counters enable-counters="True" snmp-port="0"/>
      <data-load-balancing enabled="False" auto-balancing-threshold="60%" auto-balancing-interval="30sec"/>
      <compression enable-compression="False" threshold="100kb"/>
      <client-death-detection/>
      <client-activity-notification enabled="False" retention-period="5sec"/>
      <cache-notifications item-remove="False" item-add="False" item-update="False" expiration-time="15sec"/>
      <cleanup interval="15sec"/>
      <storage type="heap" cache-size="1024mb"/>
      <eviction-policy enabled-eviction="True" default-priority="normal" policy="lru" eviction-ratio="5%"/>
      <expiration-policy enabled="False">
        <absolute-expiration longer-enabled="False" longer-value="0" default-enabled="False" default-value="0"/>
        <sliding-expiration longer-enabled="False" longer-value="0" default-enabled="False" default-value="0"/>
      </expiration-policy>
      <sql-dependency use-default="True"/>
      <synchronization strategy="polling" polling-interval="10sec"/>
      <cache-topology topology="client-cache"/>
      <client-cache-settings server-cache="demoCache" type="full-data" persist-queue="False" enable-disconnected="False" offline-queue-size="0"/>
      <tasks-config max-tasks="10" chunk-size="100" communicate-stats="False" queue-size="10" max-avoidable-exceptions="10"/>
      <split-brain-recovery enable="False" detection-interval="60"/>
    </cache-settings>
  </cache-config>

Step 2: Update the Tags in Cache Configuration

  • Update the name of the Client Cache according to your own Client Cache name in the following tag in the config.ncconf file:
<client-cache name="democlientCache" ... />
  • Change the name of the clustered cache that the Client Cache is a part of, and with which your application will connect to in the config.ncconf file:
<cache-setting>
    <client-cache-settings server-cache="demoCache" ... />
</cache-setting>
  • Update the Reference Data Types in the clustered cache configuration by updating the following tag in the config.ncconf file:
<client-cache name="democlientCache">
  <ref-datatypes enabled="True" failQueryOnPartialDataset="True" disableL2FallbackOnMiss="True" data-reload-threshold="20%">
    <ref-datatype type-name="Alachisoft.NCache.Sample.Data.Customer"/>
  </ref-datatypes>
</client-cache>

After modifying the cache configuration, the client application will need to create the cache connection and that can be done by the following two methods:

Method 1: Modify client.ncconf

From your application's local directory, open client.ncconf. Add the cache configurations as shown below for the clustered cache that the Client Cache is a part of and with which your application connects. Make sure you provide your own cache's name as provided in step 2 and the IP for the cluster in the <server ip = ... > tag.

<store name="clusteredcache">
      <servers>
        <server ip="20.200.20.40"/>
      </servers>
      <client-balancing enabled="False"/>
      <client-cache-options name="clientCache" syncmode="optimistic" skip-if-unavailable="True" reconnect-interval="10"/>
      <client-logs enabled="False" level="error"/>
</store>

Method 2: Using Client Cache Connection Options

You can connect to the cache and Client Cache using the GetCache method. For more details, refer to the Connect to Cache section in the Programmer's Guide.

// Specify the cache names
string clusteredCache = "demoCache";
string clientCache = "demoClientCache";

CacheConnectionOptions cacheConnectionOptions = new CacheConnectionOptions();
cacheConnectionOptions.LoadBalance = true;
cacheConnectionOptions.ConnectionRetries = 5;

CacheConnectionOptions clientCacheConnectionOptions = new CacheConnectionOptions();
clientCacheConnectionOptions.LoadBalance = true;
clientCacheConnectionOptions.ConnectionRetries = 5;
clientCacheConnectionOptions.Mode = IsolationLevel.OutProc;

// Connect to the caches in a single call
ICache cache = CacheManager.GetCache(clusteredCache, cacheConnectionOptions, clientCache, clientCacheConnectionOptions);

You can now perform operations on your Client Cache easily.

See Also

Enable Client Cache on Client Nodes
Disable Client Cache on Client Nodes
Remove Client Cache
Management Operations

In This Article
  • Prerequisites for Creating Client Cache
  • Step 1: Edit NCache Configuration File
    • Regular Client Cache
    • Full Data Client Cache
  • Step 2: Update the Tags in Cache Configuration
    • Method 1: Modify client.ncconf
    • Method 2: Using Client Cache Connection Options
  • See Also

Contact Us

PHONE

+1 (214) 764-6933   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache Enterprise
  • NCache Professional
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

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

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - 2025. All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top