DataCache.Add Method (String, Object, TimeSpan, Generic IEnumerable)

Adds an object to the cache. This method enables associating tags with the cached object and specifying when the object should be expired.

Namespace: Microsoft.ApplicationServer.Caching
Assembly: Microsoft.ApplicationServer.Caching.Client (in microsoft.applicationserver.caching.client.dll)

Dim instance As DataCache
Dim key As String
Dim value As Object
Dim timeout As TimeSpan
Dim tags As IEnumerable(Of DataCacheTag)
Dim returnValue As DataCacheItemVersion

returnValue = instance.Add(key, value, timeout, tags)

public DataCacheItemVersion Add (
	string key,
	Object value,
	TimeSpan timeout,
	IEnumerable<DataCacheTag> tags
public DataCacheItemVersion Add (
	String key, 
	Object value, 
	TimeSpan timeout, 
	IEnumerable<DataCacheTag> tags
public function Add (
	key : String, 
	value : Object, 
	timeout : TimeSpan, 
	tags : IEnumerable<DataCacheTag>
) : DataCacheItemVersion



A unique value that is used to store and retrieve the object from the cache.


The object saved to the cache cluster.


The amount of time that the object should reside in the cache before expiration.


An array of DataCacheTag objects to associate with the cached object.

Return Value

A DataCacheItemVersion object that represents the version of the object saved to the cache under the key value.

If an item using the same key is already present in the cache, this call throws an exception of type DataCacheException with the ErrorCode set to KeyAlreadyExists.

Tags may only be used to retrieve a cached object if that object is stored in a region. This overload does not store the object in a region.

The timeout value associated with the cached object overrides expiration settings specified in the named cache configuration. For more information, see Expiration and Eviction. For more information about how to use this method, see How to: Add an Object to Cache.

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

Development Platforms

Visual Studio 2010 and later, .NET Framework 4

Target Platforms

Windows 7; Windows Server 2008 R2; Windows Server 2008 Service Pack 2; Windows Vista Service Pack 2 2011-08-26