Language

Cache.Add Method (String, String, Object, TimeSpan)

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Adds an object to the cache. Provides the option to save the object to a region and specify an object time-out that overrides the default setting from the cache.

Namespace: System.Data.Caching
Assembly: ClientLibrary (in clientlibrary.dll)

Syntax

'Declaration
Public Function Add ( _
    region As String, _
    key As String, _
    value As Object, _
    timeOut As TimeSpan _
) As CacheItemVersion
'Usage
Dim instance As Cache
Dim region As String
Dim key As String
Dim value As Object
Dim timeOut As TimeSpan
Dim returnValue As CacheItemVersion

returnValue = instance.Add(region, key, value, timeOut)
public CacheItemVersion Add (
    string region,
    string key,
    Object value,
    TimeSpan timeOut
)
public:
CacheItemVersion^ Add (
    String^ region, 
    String^ key, 
    Object^ value, 
    TimeSpan timeOut
)
public CacheItemVersion Add (
    String region, 
    String key, 
    Object value, 
    TimeSpan timeOut
)
public function Add (
    region : String, 
    key : String, 
    value : Object, 
    timeOut : TimeSpan
) : CacheItemVersion

Parameters

  • region
    The name of the region to which to save the object. Use DefaultRegion if the object is not stored in a region.
  • key
    A unique value that is used to store and retrieve the object from the region or cache.
  • value
    The object saved to the cache cluster.
  • timeOut
    The duration of time that the object resides in the cache before expiration. This value overrides the default settings from the cache.

Return Value

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

Remarks

An exception is thrown if an item using the same key already occurs in the cache. Expiration settings specified in the timeOut parameter override those settings specified in the named cache configuration. For more information, see Expiration and Eviction (Velocity). For more information about how to use this method, see How to: Add an Object to Cache (Velocity).

See Also

Reference

Cache Class
Cache Members
System.Data.Caching Namespace