Method CreateAsync
- Namespace
- NATS.Client.KeyValueStore
- Assembly
- NATS.Client.KeyValueStore.dll
CreateAsync<T>(string, T, INatsSerialize<T>?, CancellationToken)
Create a new entry in the bucket only if it doesn't exist
public ValueTask<ulong> CreateAsync<T>(string key, T value, INatsSerialize<T>? serializer = null, CancellationToken cancellationToken = default)Parameters
- keystring
- Key of the entry 
- valueT
- Value of the entry 
- serializerINatsSerialize<T>
- Serializer to use for the message type. 
- cancellationTokenCancellationToken
- A CancellationToken used to cancel the API call. 
Returns
Type Parameters
- T
- Serialized value type 
CreateAsync<T>(string, T, TimeSpan, INatsSerialize<T>?, CancellationToken)
Create a new entry in the bucket only if it doesn't exist
public ValueTask<ulong> CreateAsync<T>(string key, T value, TimeSpan ttl = default, INatsSerialize<T>? serializer = null, CancellationToken cancellationToken = default)Parameters
- keystring
- Key of the entry 
- valueT
- Value of the entry 
- ttlTimeSpan
- Time 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. 
- serializerINatsSerialize<T>
- Serializer to use for the message type. 
- cancellationTokenCancellationToken
- A CancellationToken used to cancel the API call. 
Returns
Type Parameters
- T
- Serialized value type