Constructor CacheDependency
CacheDependency()
Default constructor for Cache
Declaration
public CacheDependency()
CacheDependency(CustomDependency)
Creates a Cache
Declaration
public CacheDependency(CustomDependency customDependency)
Parameters
Type | Name | Description |
---|---|---|
Custom |
customDependency | CustomDependency instance. |
CacheDependency(ExtensibleDependency)
Creates a Cache
Declaration
public CacheDependency(ExtensibleDependency extensibleDependency)
Parameters
Type | Name | Description |
---|---|---|
Extensible |
extensibleDependency | ExtensibleDependency instance. |
CacheDependency(String)
Initializes a new instance of the Cache
Declaration
public CacheDependency(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System. |
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 fileNames 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 cache, the cached object will be removed from the cache.
Let's assume that you add an object to the cache with a dependency on the following
file path: c:\stocks\xyz.dat. If that file is not found when the Cache
Examples
The following example demonstrates how to create an instance of the Cache
// 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 Cache
Declaration
public CacheDependency(string fileName, DateTime start)
Parameters
Type | Name | Description |
---|---|---|
System. |
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. |
System. |
start | The time against which to check the last modified date of the directory or file. |
Remarks
If the directory or file specified in the fileNames 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 cache, the cached object will be removed from the cache.
Let's assume that you add an object to the cache with a dependency on the following
file path: c:\stocks\xyz.dat. If that file is not found when the Cache
Examples
The following example demonstrates how to create an instance of the Cache
// 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. |
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 cache object.
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 cache, the cached object will be removed from the cache. Let's
assume that you add an object to the cache with a dependency on the following file path:
c:\stocks\xyz.dat. If that file is not found when the Cache
Exceptions
Type | Condition |
---|---|
System. |
fileNames contains a null reference. |
CacheDependency(String[], DateTime)
Initializes a new instance of the Cache
Declaration
public CacheDependency(string[] fileNames, DateTime start)
Parameters
Type | Name | Description |
---|---|---|
System. |
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. |
start | The time against which to check the last modified date of the directory or file. |
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 cache object.
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 cache, the cached object will be removed from the cache. Let's
assume that you add an object to the cache with a dependency on the following file path:
c:\stocks\xyz.dat. If that file is not found when the Cache
Exceptions
Type | Condition |
---|---|
System. |
fileNames contains a null reference. |
CacheDependency(String[], String[])
Initializes a new instance of the Cache
Declaration
public CacheDependency(string[] fileNames, string[] cacheKeys)
Parameters
Type | Name | Description |
---|---|---|
System. |
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. |
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 cache object.
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 cache, the cached object will be removed from the cache. Let's
assume that you add an object to the cache with a dependency on the following file path:
c:\stocks\xyz.dat. If that file is not found when the Cache
Examples
The following code fragment demonstrates how to insert an item into your application's cache with a dependency on a key to another item placed in the cache. Since this method uses array syntax, you must define the number of keys the item you are adding to the cache is dependent on.
CacheDependency(String[], String[], DateTime)
Initializes a new instance of the Cache
Declaration
public CacheDependency(string[] fileNames, string[] cacheKeys, DateTime start)
Parameters
Type | Name | Description |
---|---|---|
System. |
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. |
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. |
System. |
start | The time against which to check the last modified date of the directory or file. |
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 cache object.
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 cache, the cached object will be removed from the cache. Let's,
assume that you add an object to the cache with a dependency on the following file path:
c:\stocks\xyz.dat. If that file is not found when the Cache
Exceptions
Type | Condition |
---|---|
System. |
fileNames or cacheKeys contains a null reference. |
CacheDependency(String[], String[], CacheDependency)
Initializes a new instance of the Cache
Declaration
public CacheDependency(string[] fileNames, string[] cacheKeys, CacheDependency dependency)
Parameters
Type | Name | Description |
---|---|---|
System. |
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. |
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. |
Cache |
dependency | Another instance of 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 cache object.
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 cache, the cached object will be removed from the cache. Let's, assume that you add an object to the cache with a dependency on the following file path:
c:\stocks\xyz.dat. If that file is not found when the Cache
Exceptions
Type | Condition |
---|---|
System. |
fileNames or cacheKeys contains a null reference. |
CacheDependency(String[], String[], CacheDependency, DateTime)
Initializes a new instance of the Cache
Declaration
public CacheDependency(string[] fileNames, string[] cacheKeys, CacheDependency dependency, DateTime start)
Parameters
Type | Name | Description |
---|---|---|
System. |
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. |
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. |
Cache |
dependency | Another instance of the Cache |
System. |
start | The time against which to check the last modified date of the directory or file. |
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 cache object.
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 cache, the cached object will be removed from the cache. Let's,
assume that you add an object to the cache with a dependency on the following file path:
c:\stocks\xyz.dat. If that file is not found when the Cache
Exceptions
Type | Condition |
---|---|
System. |
fileNames or cacheKeys contains a null reference. |