AggregateCacheDependency Class

AggregateCacheDependency Class


Combines multiple dependencies between an item stored in an ASP.NET application's Cache object and an array of CacheDependency objects. This class cannot be inherited.

Namespace:   System.Web.Caching
Assembly:  System.Web (in System.Web.dll)


public sealed class AggregateCacheDependency : CacheDependency


Initializes a new instance of the AggregateCacheDependency class.


Gets a value indicating whether the CacheDependency object has changed.(Inherited from CacheDependency.)


Gets the time when the dependency was last changed.(Inherited from CacheDependency.)


Adds an array of CacheDependency objects to the AggregateCacheDependency object.


Releases the resources used by the CacheDependency object.(Inherited from CacheDependency.)


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Completes initialization of the CacheDependency object.(Inherited from CacheDependency.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

The AggregateCacheDependency class monitors a collection of dependency objects so that when any of them change, the cached item is automatically removed. The objects in the array can be CacheDependency objects, SqlCacheDependency objects, custom objects derived from CacheDependency, or any combination of these.

The AggregateCacheDependency class differs from the CacheDependency class in that it allows you to associate multiple dependencies of different types with a single cached item. For example, if you create a page that imports data from a SQL Server database table and an XML file, you can create a SqlCacheDependency object to represent a dependency on the database table and a CacheDependency to represent the dependency on the XML file. Rather than making an Cache.Insert method call for each dependency, you can create an instance of the AggregateCacheDependency class with each dependency added to it. You can then use a single Insert call to make the page dependent on the AggregateCacheDependency instance.

The following code example uses the AggregateCacheDependency class to add a DataSet, named XMLDataSet, to the cache that is dependent on a text file and an XML file.

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2015 Microsoft