Alachisoft NCache 4.1 - Online Documentation

Client Cache Overview

When your application resides on a remote client node, accessing the clustered cache remotely, you may want to have a cache on client node to hold a subset of the clustered cache. This client cache (L1 cache) sits on top of the clustered cache (L2 cache), giving further performance boost by reducing trips to the clustered cache. NCache makes sure that your client cache is always synchronized with the clustered cache to avoid data integrity problem.
When application adds data to the clustered cache, it also adds it to the client cache and specifies a cache sync dependency between items in the local and remote cache. Whenever another application changes item in the clustered cache, an event is sent to the client cache to update copy of that item.
NCache provides a new overload of NCache.InitializeCache to help you use the cache sync dependency seamlessly. You do not need to perform operations to both L1 and L2 caches and specify the dependency yourself. The new overload for InitializeCache takes two cache ids, one of L1 cache and other of L2 cache, and returns a cache object. Internally it initializes both caches, you can get their instances from NCache.Caches property. Once you have the instance, you can use the existing API as always. Operations are performed on L1 and L2 caches as follows:
  • Add, Insert, Remove operations are now done on both L1 and L2 caches.
  • The Get operation is performed on L1 cache first. If the item is not found in L1, L2 will be contacted. Once item is found in L2 cache, it will be added to L1 cache as well.
  • All other functions like Search, Contains, Get Enumerator, and fields like ExceptionsEnabled and Count will be performed on L2 cache.
  • All notifications will be of L2 cache.
You can also use client cache by specifying the client-cache-id in client.ncconf. The cache entry in client.ncconf should be modified as follows.
<cache id ="remotecache" client-cache-id="mylocalcache" load-balance="true">
<server name=""/>
<cache id ="mylocalcache" load-balance="true">
<server name=""/>
    See Also
Copyright © 2005-2012 Alachisoft. All rights reserved.