Method AddAsync
AddAsync(TKey, TValue, CreatePolicy, IEnumerable<string>, CancellationToken)
Adds an object in the cache.
public Task<CacheResponse<TKey, TValue>> AddAsync(TKey key, TValue value, CreatePolicy createPolicy = null, IEnumerable<string> tags = null, CancellationToken cancellationToken = default)
Parameters
keyTKeyIdentifier of the object in the cache.
valueTValueValue to be stored in the cache.
createPolicyCreatePolicyThe policy to be associated with the new object. If
null, the default policy for the cache will be used.tagsIEnumerable<string>Collection of tags to associate with the object. Pass null for no tags.
cancellationTokenCancellationTokenA 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:
| ServerResult | Description |
|---|---|
| Added | A new object was successfully added in the ScaleOut service. |
| AlreadyExistsError | The object could not be added because another object with the same key already exists in the ScaleOut service. |