Table of Contents

Method AddOrUpdateAsync

Namespace
Scaleout.Client
Assembly
Scaleout.Client.dll

AddOrUpdateAsync(TKey, TValue, CreatePolicy, IEnumerable<string>, CancellationToken)

Adds or updates an object in the cache.

public Task<CacheResponse<TKey, TValue>> AddOrUpdateAsync(TKey key, TValue value, CreatePolicy createPolicy = null, IEnumerable<string> tags = null, CancellationToken cancellationToken = default)

Parameters

key TKey

Identifier of the object in the cache.

value TValue

Value to be stored in the cache.

createPolicy CreatePolicy

The 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 CancellationToken

A token used to propagate notification that this operation should be canceled.

Returns

Task<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:

ServerResultDescription
AddedA new object was successfully added in the ScaleOut service.
UpdatedAn 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.