Method TakeAsync
TakeAsync<T>(IShortLivedStore, string, string, JsonTypeInfo<T>, ILogger?, CancellationToken)
Gets and removes a state, or returns null if it does not exist or cannot be read as the state, which is logged as a warning to
logger, if one is given. A state is returned at most once, even when it is taken by concurrent calls.
Declaration
public static ValueTask<T?> TakeAsync<T>(this IShortLivedStore store, string keyPrefix, string id, JsonTypeInfo<T> typeInfo, ILogger? logger = null, CancellationToken cancellationToken = default) where T : class
Parameters
| Type | Name | Description |
|---|---|---|
| IShortLivedStore | store | The store. |
| string | keyPrefix | The start of the key, as the state was added with. |
| string | id | The ID of the state within the prefix. |
| JsonTypeInfo<T> | typeInfo | The JSON type information of the state. |
| ILogger | logger | The logger that a state that cannot be read is logged to, if any. |
| CancellationToken | cancellationToken | A token to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<T> |
Type Parameters
| Name | Description |
|---|---|
| T |