Constructor CacheDependency
CacheDependency()
Default constructor for CacheDependency class
Declaration
public CacheDependency()
CacheDependency(ExtensibleDependency)
Creates a CacheDependency instance from extensible dependency.
Declaration
public CacheDependency(ExtensibleDependency extensibleDependency)
Parameters
Type | Name | Description |
---|---|---|
ExtensibleDependency | extensibleDependency | ExtensibleDependency hint. |
CacheDependency(String)
Initializes a new instance of the CacheDependency class that monitors a file or directory for changes.
Declaration
public CacheDependency(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | 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. |
Remarks
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
For example, assume that you add an object to the
Examples
The following example demonstrates code that creates an instance of the CacheDependency class
when an item is inserted in the
// Make key1 dependent on a file.
CacheDependency dependency = new CacheDependency(Server.MapPath("isbn.xml"));
Cache cache = NCache.InitializeCache("demoClusteredCache");
cache.Insert("key1", "Value 1", dependency);
CacheDependency(String, DateTime)
Initializes a new instance of the CacheDependency class that monitors a file or directory for changes and indicates when change tracking is to begin.
Declaration
public CacheDependency(string fileName, DateTime start)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | 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. |
DateTime | start | The time when change tracking begins. |
Remarks
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
For example, assume that you add an object to the
Examples
The following example demonstrates code that creates an instance of the CacheDependency class
when an item is inserted in the
// Make key1 dependent on a file.
CacheDependency dependency = new CacheDependency(Server.MapPath("isbn.xml"), DateTime.Now.AddMinutes(10));
Cache cache = NCache.InitializeCache("demoClusteredCache");
cache.Insert("key1", "Value 1", dependency);
CacheDependency(String[])
Initializes a new instance of the CacheDependency class that monitors an array of file paths (to files or directories) for changes.
Declaration
public CacheDependency(string[] fileNames)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | fileNames | An array of file paths (to files or directories) that the cached object is dependent upon. When any of these resources change, the cached object becomes obsolete and is removed from the cache. |
Remarks
If any of the files or directories in the array were to change or be removed from the array,
the cached item becomes obsolete and is removed from the application's
Also, if any of the directories or files specified in the fileNames
parameter is not found in the
file system, they are treated as missing files. If any of them are created after the object with the
dependency is added to the
CacheDependency(String[], DateTime)
Initializes a new instance of the CacheDependency class that monitors an array of file paths (to files or directories) for changes and specifies a time when change monitoring begins.
Declaration
public CacheDependency(string[] fileNames, DateTime start)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | fileNames | An array of file paths (to files or directories) that the cached object is dependent upon. When any of these resources change, the cached object becomes obsolete and is removed from the cache. |
DateTime | start | The time when change tracking begins. |
Remarks
If any of the files or directories in the array were to change or be removed from the array,
the cached item becomes obsolete and is removed from the application's
Also, if any of the directories or files specified in the fileNames
parameter is not found in the
file system, they are treated as missing files. If any of them are created after the object with the
dependency is added to the
CacheDependency(String[], String[])
Initializes a new instance of the CacheDependency class that monitors an array of file paths (to files or directories), an array of cache keys, or both for changes.
Declaration
public CacheDependency(string[] fileNames, string[] cacheKeys)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | fileNames | An array of file paths (to files or directories) that the cached object is dependent upon. When any of these resources change, the cached object becomes obsolete and is removed from the cache. |
System.String[] | cacheKeys | An array of cache keys that the new object monitors for changes. When any of these cache keys change, the cached object associated with this dependency object becomes obsolete and is removed from the cache. |
Remarks
If any of the files or directories in the array were to change or be removed from the array,
the cached item becomes obsolete and is removed from the application's
Also, if any of the directories or files specified in the fileNames
parameter is not found in the
file system, they are treated as missing files. If any of them are created after the object with the
dependency is added to the
fileNames
or cacheKeys
contains a
null reference (Nothing in Visual Basic).Examples
The following code fragment demonstrates how to insert an item into your application's
CacheDependency(String[], String[], DateTime)
Initializes a new instance of the CacheDependency class that monitors an array of file paths (to files or directories), an array of cache keys, or both for changes.
Declaration
public CacheDependency(string[] fileNames, string[] cacheKeys, DateTime start)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | fileNames | An array of file paths (to files or directories) that the cached object is dependent upon. When any of these resources change, the cached object becomes obsolete and is removed from the cache. |
System.String[] | cacheKeys | An array of cache keys that the new object monitors for changes. When any of these cache keys change, the cached object associated with this dependency object becomes obsolete and is removed from the cache. |
DateTime | start | The time when change tracking begins. |
Remarks
If any of the files or directories in the array were to change or be removed from the array,
the cached item becomes obsolete and is removed from the application's
Also, if any of the directories or files specified in the fileNames
parameter is not found in the
file system, they are treated as missing files. If any of them are created after the object with the
dependency is added to the
CacheDependency(String[], String[], CacheDependency)
Initializes a new instance of the CacheDependency class that monitors an array of file paths (to files or directories), an array of cache keys, or both for changes. It also makes itself dependent upon a separate instance of the CacheDependency class.
Declaration
public CacheDependency(string[] fileNames, string[] cacheKeys, CacheDependency dependency)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | fileNames | An array of file paths (to files or directories) that the cached object is dependent upon. When any of these resources change, the cached object becomes obsolete and is removed from the cache. |
System.String[] | cacheKeys | An array of cache keys that the new object monitors for changes. When any of these cache keys change, the cached object associated with this dependency object becomes obsolete and is removed from the cache. |
CacheDependency | dependency | Another instance of the CacheDependency class that this instance is dependent upon. |
Remarks
If any of the files or directories in the array were to change or be removed from the array,
the cached item becomes obsolete and is removed from the application's
Also, if any of the directories or files specified in the fileNames
parameter is not found in the
file system, they are treated as missing files. If any of them are created after the object with the
dependency is added to the
CacheDependency(String[], String[], CacheDependency, DateTime)
Initializes a new instance of the CacheDependency class that monitors an array of file paths (to files or directories), an array of cache keys, or both for changes. It also makes itself dependent upon another instance of the CacheDependency class and a time when the change monitoring begins.
Declaration
public CacheDependency(string[] fileNames, string[] cacheKeys, CacheDependency dependency, DateTime start)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | fileNames | An array of file paths (to files or directories) that the cached object is dependent upon. When any of these resources change, the cached object becomes obsolete and is removed from the cache. |
System.String[] | cacheKeys | An array of cache keys that the new object monitors for changes. When any of these cache keys change, the cached object associated with this dependency object becomes obsolete and is removed from the cache. |
CacheDependency | dependency | Another instance of the CacheDependency class that this instance is dependent upon. |
DateTime | start | The time when change tracking begins. |
Remarks
If any of the files or directories in the array were to change or be removed from the array,
the cached item becomes obsolete and is removed from the application's
Also, if any of the directories or files specified in the fileNames
parameter is not found in the
file system, they are treated as missing files. If any of them are created after the object with the
dependency is added to the