Language

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

[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. This method provides the option to save the object to a region and enables associating tags with the cached object.

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

Syntax

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

returnValue = instance.Add(region, key, value, tags)
public CacheItemVersion Add (
    string region,
    string key,
    Object value,
    Tag[] tags
)
public:
CacheItemVersion^ Add (
    String^ region, 
    String^ key, 
    Object^ value, 
    array<Tag^>^ tags
)
public CacheItemVersion Add (
    String region, 
    String key, 
    Object value, 
    Tag[] tags
)
public function Add (
    region : String, 
    key : String, 
    value : Object, 
    tags : Tag[]
) : CacheItemVersion

Parameters

  • region
    The name of the region to save the object in. If DefaultRegion is used, the object is not saved to a region and the tags are ignored.
  • key
    A unique value that is used to store and retrieve the object from cache.
  • value
    The object saved to the cache cluster.
  • tags
    An array of Tag objects to associate with the cached object inside the region. If the region name is not provided, all tags are ignored.

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 is already located in the cache. Expiration settings are derived from 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).

Tags may only be used to retrieve a cached object if that object is saved to a region. Until a region name is provided, tags are ignored.

See Also

Reference

Cache Class
Cache Members
System.Data.Caching Namespace