Initializes a new instance of the CacheDependency class that monitors a file or directory for changes and indicates when change tracking is to begin.Namespace: Alachisoft.NCache.Runtime.Dependencies
Assembly: Alachisoft.NCache.Runtime (in Alachisoft.NCache.Runtime.dll) Version: 22.214.171.124 (126.96.36.199)
If the directory or file specified in the fileName parameter is not found in the file system, it will be treated as a missing file. If the file is created after the object with the dependency is added to the , the cached object will be removed from the .
For example, assume that you add an object to the CacheDependency object is created, but is created later, the cached object is removed upon the creation of the xyz.dat file.with a dependency on the following file path: c:\stocks\xyz.dat. If that file is not found when the
The following example demonstrates code that creates an instance of the CacheDependency class when an item is inserted in the with a dependency on an XML file. The tracking start time is set to 10 minutes in the future.
// Make key1 dependent on a file. CacheDependency dependency = new CacheDependency(Server.MapPath("isbn.xml"), DateTime.Now.AddMinutes(10)); Cache cache = NCache.InitializeCache("myCache"); cache.Insert("key1", "Value 1", dependency);