Establishes a dependency relationship between an item stored in an ASP.NET application's Cache object and a file, cache key, an array of either, or another CacheDependency object. The CacheDependency class monitors the dependency relationships so that when any of them changes, the cached item will be automatically removed.
public ref class CacheDependency sealed : IDisposable
public ref class CacheDependency : IDisposable
public sealed class CacheDependency : IDisposable
public class CacheDependency : IDisposable
type CacheDependency = class
interface IDisposable
Public NotInheritable Class CacheDependency
Implements IDisposable
Public Class CacheDependency
Implements IDisposable
The following code example demonstrates using the HasChanged property to determine whether a CacheDependency changed since the previous request for an item in the Cache. The dt
value passed in the start
parameter is set to DateTime.Now.
// Insert the cache item.
CacheDependency dep = new CacheDependency(fileName, dt);
cache.Insert("key", "value", dep);
// Check whether CacheDependency.HasChanged is true.
if (dep.HasChanged)
Response.Write("<p>The dependency has changed.");
else Response.Write("<p>The dependency has not changed.");
' Insert the cache item.
Dim dep As New CacheDependency(fileName, dt)
myCache.Insert("key", "value", dep)
' Check whether CacheDependency.HasChanged is true.
If dep.HasChanged Then
Response.Write("<p>The dependency has changed.")
Else
Response.Write("<p>The dependency has not changed.")
End If
If you add an item to the cache that is dependent on another object, such as a file or array of files, the dependent item is automatically removed from the cache when the object changes. For example, suppose you create a DataSet object based on data in an XML file. You can add the DataSet to the cache with a CacheDependency object that makes the DataSet dependent on the XML file. If the XML file changes, the DataSet is removed from the cache.
You can add items with dependencies to your application's cache with the Add and Cache.Insert methods. You cannot use the Item[] property to add items to the cache with dependencies.
To set up a dependency, you create an instance of the CacheDependency class, specifying the files, keys, or directories on which the item is dependent, and then pass the dependency to the Add or Cache.Insert method. The CacheDependency instance can represent a single file or directory, an array of files or directories, or an array of files or directories along with an array of cache keys (these represent other items stored in the Cache object).
Constructors CacheDependency()Initializes a new instance of the CacheDependency class.
CacheDependency(String, DateTime)Initializes a new instance of the CacheDependency class that monitors a file or directory for changes.
CacheDependency(String)Initializes a new instance of the CacheDependency class that monitors a file or directory for changes.
CacheDependency(String[], DateTime)Initializes a new instance of the CacheDependency class that monitors an array of paths (to files or directories) for changes and specifies a time when change monitoring begins.
CacheDependency(String[], String[], CacheDependency, DateTime)Initializes a new instance of the CacheDependency class that monitors an array of 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.
CacheDependency(String[], String[], CacheDependency)Initializes a new instance of the CacheDependency class that monitors an array of 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.
CacheDependency(String[], String[], DateTime)Initializes a new instance of the CacheDependency class that monitors an array of paths (to files or directories), an array of cache keys, or both for changes.
CacheDependency(String[], String[])Initializes a new instance of the CacheDependency class that monitors an array of paths (to files or directories), an array of cache keys, or both for changes.
CacheDependency(String[])Initializes a new instance of the CacheDependency class that monitors an array of paths (to files or directories) for changes.
Properties Methods See alsoRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4