NCache 4.4 - 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.
 
Product product=new Product();
product.ProductID=1002;
product.ProductName="Chang";
string key="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