Method AddOrUpdate
AddOrUpdate(TKey, TValue, CreatePolicy, IEnumerable<string>, CancellationToken)
Adds or updates an object in the cache.
public CacheResponse<TKey, TValue> AddOrUpdate(TKey key, TValue value, CreatePolicy createPolicy = null, IEnumerable<string> tags = null, CancellationToken cancellationToken = default)
Parameters
key
TKeyIdentifier of the object in the cache.
value
TValueValue to be stored in the cache.
createPolicy
CreatePolicyThe policy to be associated with the object in the data grid if the AddOrUpdate operation results in the insertion of a new object into the cache. If
null
, the default policy for the cache will be used.tags
IEnumerable<string>Collection of tags to associate with the object. All tags are replaced with the provided collection. Pass null for no tags on a new object or to leave current tags in place on an existing object. An empty collection clears tags on an existing object.
cancellationToken
CancellationTokenA token used to propagate notification that this operation should be canceled.
Returns
- CacheResponse<TKey, TValue>
A CacheResponse<TKey, TValue> containing the outcome of the operation.
Remarks
The Result property of the response will contain one of the following ServerResult outcomes:
ServerResult | Description |
---|---|
Added | A new object was successfully added in the ScaleOut service. |
Updated | An existing object was successfully updated in the ScaleOut service. |
This operation does not use locking and will bypass locks on objects held by other clients/threads.