NCache 4.6 - Online Documentation

Aggregate Cache Dependency

 
NCache provides feature of Aggregate dependency to support multiple dependencies with a single cache item. The following code explains how to add AggregateCacheDependency with an item.
 
      To utilize the API, include the following namespace in your application: Alachisoft.NCache.Runtime.Dependencies.
 
            Product product1 = new Product();
            product1.ProductID = 1002;
            product1.ProductName = "Chang";
 
            string key1 = "Product:" + product.ProductID;
            try
            {
                //Initializing Aggregate Dependency; Item dependant on File and Key
                AggregateCacheDependency aggregateDependency = new AggregateCacheDependency();
 
                aggregateDependency.Dependencies.Add(new FileDependency("C:\\tempProductList.txt"));
 
                aggregateDependency.Dependencies.Add(new KeyDependency("Product:1001"));
 
                //Inserting item with AggregateCacheDependency
                cache.Insert(key, product, aggregateDependency, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,                CacheItemPriority.Normal);
            }
            catch (OperationFailedException e)
            {
                // handle exception
            }
 
 
See Also