NCache 4.6 - Online Documentation

Sample Usage of Custom Dependency

Adding Data with Custom Dependency
Once custom dependency class has been implemented and deployed, its ready to be used in your program. Following code shows how to use custom dependency:
       To utilize the Insert API, include the following namespace in your application: Alachisoft.NCache.Web.Caching.
            string connString = "Provider=SQLOLEDB.1;Data Source=localhost;User ID=sa;password=;Initial Catalog=Northwind";
            //Creating custom dependency
            CustomDependency customDependency = new CustomDependency(123, connString);
            Product product = new Product();
            product.ProductID = 1001;
            product.ProductName = "Chai";
            string key = "Product:" + product.ProductID;
                //Adding data with custom dependency
                cache.Insert(key, product, new CacheDependency(customDependency), Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,                     CacheItemPriority.Default);
            catch (OperationFailedException exp)
                // handle exception
See Also