Cache.Insert Method (String, Object)

Inserts an item into the Cache object with a cache key to reference its location, using default values provided by the CacheItemPriority enumeration.

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

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

Parameters

key

The cache key used to reference the item.

value

The object to be inserted into the cache.

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.

No code example is currently available or this language may not be supported.
get_Cache().Insert("DSN", connectionString);

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: