Language
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[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 and specifying how long the object should remain in 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, _
tags As Tag(), _
timeOut As TimeSpan _
) As CacheItemVersion
'Usage
Dim instance As Cache
Dim region As String
Dim key As String
Dim value As Object
Dim tags As Tag()
Dim timeOut As TimeSpan
Dim returnValue As CacheItemVersion
returnValue = instance.Add(region, key, value, tags, timeOut)
public CacheItemVersion Add (
string region,
string key,
Object value,
Tag[] tags,
TimeSpan timeOut
)
public:
CacheItemVersion^ Add (
String^ region,
String^ key,
Object^ value,
array<Tag^>^ tags,
TimeSpan timeOut
)
public CacheItemVersion Add (
String region,
String key,
Object value,
Tag[] tags,
TimeSpan timeOut
)
public function Add (
region : String,
key : String,
value : Object,
tags : Tag[],
timeOut : TimeSpan
) : CacheItemVersion
Parameters
- region
The name of the region to save the object. 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.
- timeOut
A non-zero time to live (TTL) value that is used to specify how many minutes the object should reside in the cache before expiration.
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.
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.
The timeOut value associated with the cached object overrides expiration 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).