Initializes a new instance of the CacheDependency class that monitors a file or directory for changes.Namespace: Alachisoft.NCache.Runtime.Dependencies
Assembly: Alachisoft.NCache.Runtime (in Alachisoft.NCache.Runtime.dll) Version: 18.104.22.168 (22.214.171.124)
public CacheDependency( string fileName )
Public Sub New ( _ fileName As String _ )
public: CacheDependency( String^ fileName )
- Type: System..::..String
The path to a file or directory that the cached object is dependent upon. When this resource changes, the cached object becomes obsolete and is removed from the cache.
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.
// Make key1 dependent on a file. CacheDependency dependency = new CacheDependency(Server.MapPath("isbn.xml")); Cache cache = NCache.InitializeCache("myCache"); cache.Insert("key1", "Value 1", dependency);