| CacheDependency | disposable |
| System.Web.Caching (system.web.dll) | sealed class |
Cache dependencies allow the validity of a cache item to be based on
a file or directory on the web server, or on another cache item. When
the dependency object changes, the dependent cache item is
invalidated and removed automatically. To set up a dependency, you
first create a CacheDependency object that
references the file, directory, or cache item upon which the
dependency will be based. You then use the Cache.Insert(
) method to add the dependent cache item, with the
CacheDependency object supplied as a parameter.
The overloaded constructor of the CacheDependency
class determines the type of dependency. You can pass a single string
argument to set up a dependency on a file or directory
(CacheDependency(Server.MapPath("data.xml")) or
you can use a second string argument with the key of another cache
item (CacheDependency(Nothing,
"MyData")). Other versions of the constructor
allow you to specify an array of strings specifying files or cache
objects. If any one file or object changes, the dependent cache item
will be invalidated.
The CacheDependency object begins to monitor for
changes as soon as it is created to account for changes that may
occur in the brief delay before the dependent cache item is added to
the Cache class.
public sealed class CacheDependency : IDisposable {
// Public Constructors
public
CacheDependency (string
filename );
public
CacheDependency (string[ ]
filenames );
public
CacheDependency (string[ ]
filenames , DateTime
start );
public
CacheDependency (string[ ]
filenames , string[ ]
cachekeys );
public
CacheDependency (string[ ]
filenames , string[ ]
cachekeys , CacheDependency
dependency );
public
CacheDependency (string[ ]
filenames , string[ ]
cachekeys , CacheDependency
dependency , DateTime
start );
public
CacheDependency (string[ ]
filenames , string[ ]
cachekeys , DateTime
start );
public
CacheDependency (string
filename , DateTime
start );
// Public Instance Properties
public bool
HasChanged {get; }
// Public Instance Methods
public void
Dispose ( ); // implements IDisposable
}
Returned By
System.Web.UI.BasePartialCachingControl.Dependency
Passed To
Cache.{Add( ), Insert( )},
System.Web.UI.BasePartialCachingControl.Dependency