Method TryUpdateAsync
- Namespace
- NATS.Client.KeyValueStore
- Assembly
- NATS.Client.KeyValueStore.dll
TryUpdateAsync<T>(string, T, ulong, INatsSerialize<T>?, CancellationToken)
Tries to update an entry in the bucket only if last update revision matches
public ValueTask<NatsResult<ulong>> TryUpdateAsync<T>(string key, T value, ulong revision, INatsSerialize<T>? serializer = null, CancellationToken cancellationToken = default)
Parameters
key
stringKey of the entry
value
TValue of the entry
revision
ulongLast revision number to match
serializer
INatsSerialize<T>Serializer to use for the message type.
cancellationToken
CancellationTokenA CancellationToken used to cancel the API call.
Returns
- ValueTask<NatsResult<ulong>>
A NatsResult object representing the revision number of the updated entry or an error.
Type Parameters
T
Serialized value type
Remarks
Use this method to avoid exceptions
TryUpdateAsync<T>(string, T, ulong, TimeSpan, INatsSerialize<T>?, CancellationToken)
Tries to update an entry in the bucket only if last update revision matches
public ValueTask<NatsResult<ulong>> TryUpdateAsync<T>(string key, T value, ulong revision, TimeSpan ttl, INatsSerialize<T>? serializer = null, CancellationToken cancellationToken = default)
Parameters
key
stringKey of the entry
value
TValue of the entry
revision
ulongLast revision number to match
ttl
TimeSpanTime to live for the entry (requires the LimitMarkerTTL to be set to true). For a key that should never expire, use the MaxValue constant. This feature is only available on NATS server v2.11 and later.
serializer
INatsSerialize<T>Serializer to use for the message type.
cancellationToken
CancellationTokenA CancellationToken used to cancel the API call.
Returns
- ValueTask<NatsResult<ulong>>
A NatsResult object representing the revision number of the updated entry or an error.
Type Parameters
T
Serialized value type
Remarks
Use this method to avoid exceptions