Method SetAsync
SetAsync(string, string, TimeSpan, CancellationToken)
Sets the value of a key, replacing whatever the key holds, a value or a counter, and sets it to expire after the lifetime, counted from now.
Declaration
ValueTask SetAsync(string key, string value, TimeSpan lifetime, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key. |
| string | value | The value. |
| TimeSpan | lifetime | How long the value is kept. Must be greater than zero. |
| CancellationToken | cancellationToken | A token to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask |
Remarks
The key has a value throughout: a read at the same time gets the value it held before or the new one.