HttpResponse.AddCacheItemDependency Method (String)

 

Makes the validity of a cached response dependent on another item in the cache.

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

member AddCacheItemDependency : 
        cacheKey:string -> unit

Parameters

cacheKey
Type: System.String

The key of the item that the cached response is dependent upon.

When the item corresponding to the cacheKey parameter is removed from the cache, the cached response of the current item is invalid.

The following example is an ASP.NET user control that is output cached. The code for the control calls the AddCacheItemDependency method with the key of an item stored in the Cache object passed as its parameter. If the item does not exist in the cache, the control's response that was stored in the output cache is invalidated. This means that on the subsequent request, a new version of the control's response will be added to the output cache.

Next, the code checks whether an item associated with a bookData key is stored in the Cache object, and displays one of two lines of text dependent upon the result. Then, the code sets the DataSource property of a DataGrid control, which is named dgBooks, with a call to a custom DataHelper class' shared GetBookData method, and populates the DataGrid with the DataBind method.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: