Alachisoft NCache 4.1 - Online Documentation

Cache Sync Dependency

 
NOTE: This feature is not available in NCache Express and Professional edition.
 
Cache sync dependency provides a way to synchronize two caches, so that an item updated or removed from one cache have an same effect on the synchronized cache. For example, you can have a Local Cache that keeps items frequently used by your application and a Clustered Cache that keeps a larger number of items being shared with other applications. And, your local items are kept synchronized with the clustered cache so you never have any data integrity problems while improving your app performance even further.
 
Include the following namespaces in your application:
 
using Alachisoft.NCache.Web.Caching;
using Alachisoft.NCache.Runtime;
using Alachisoft.NCache.Runtime.Dependencies;
 
Following code snippet shows how CacheSyncDependency can be utilized:
 
Cache cache1 = NCache.InitializeCache("myCache");
Cache cache2 = NCache.InitializeCache("myReplicatedCache");
cache1.ExceptionsEnabled = true;
cache2.ExceptionsEnabled = true;
for (int i = 0; i < 10; i++)
{
cache2.Add(i.ToString(), i);
}
for (int i = 0; i < 10; i++)
{
cache1.Add(i.ToString(), cache2.Get(i.ToString()), new CacheSyncDependency("myReplicatedCache", i.ToString()), Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, Alachisoft.NCache.Runtime.CacheItemPriority.Default);
}
 
 
See Also
 
Copyright © 2005-2012 Alachisoft. All rights reserved.