NCache 4.4 - Online Documentation

Add Dependency to the Existing Cached Item

 
If data has been added to cache without dependency, NCache allows to add any of the dependency supported by NCache, with this existing data without any need of updating data. This can be done using AddDependency API of NCache.
 
The following code shows how to add dependency with existing data.
 
string key1="Product:1001";
string key2="Product:1002";
// precondition: items with keys "Product:1001" and Product:1002" are already in cache
 
try
{
cache.AddDependency(key2, new KeyDependency(key1), false);
}
catch (OperationFailedException ex)
{
    // handle exception
}
 
To add file dependency use:
 
cache.AddDependency(key, new FileDependency(filepath), false);
 
Any dependency can be added with the existing cached item with the same API.
 
 
See Also