Cache.Insert Method (String, Object, CacheDependency)

Inserts an object into the Cache that has file or key dependencies.

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

public:
void Insert (
	String^ key, 
	Object^ value, 
	CacheDependency^ dependencies
)
public void Insert (
	String key, 
	Object value, 
	CacheDependency dependencies
)
public function Insert (
	key : String, 
	value : Object, 
	dependencies : CacheDependency
)
Not applicable.

Parameters

key

The cache key used to identify the item.

value

The object to be inserted in the cache.

dependencies

The file or cache key dependencies for the inserted object. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this parameter contains a null reference (Nothing in Visual Basic).

Exception typeCondition

ArgumentNullException

The key or value parameter is a null reference (Nothing in Visual Basic).

This method will overwrite an existing cache item whose key matches the key parameter. The object added to the cache using this overload of the Insert method is inserted with no file or cache dependencies, a priority of Default, a sliding expiration value of NoSlidingExpiration, and an absolute expiration value of NoAbsoluteExpiration.

The following example demonstrates how to insert an item into an application's cache with a cache dependency on an XML configuration file.

No code example is currently available or this language may not be supported.
get_Cache().Insert("DSN", connectionString, 
    new CacheDependency(get_Server().MapPath("myconfig.xml")));

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: