Method AddAsync
AddAsync(IShortLivedStore, string, string, TimeSpan, CancellationToken)
Adds a value under a new random key and returns the random part of the key. The value is stored under keyPrefix followed by the
returned value, which the next step of a flow presents.
Declaration
public static ValueTask<string> AddAsync(this IShortLivedStore store, string keyPrefix, string value, TimeSpan lifetime, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IShortLivedStore | store | The store. |
| string | keyPrefix | The start of the key, which keeps the values of one flow apart from all others, for example |
| string | value | The value. |
| TimeSpan | lifetime | How long the value is kept. Must be positive. |
| CancellationToken | cancellationToken | A token to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<string> | The random part of the key: 256 random bits as 43 URL-safe characters. It cannot be guessed, so it can serve as the secret that a client presents to continue the flow. |
AddAsync<T>(IShortLivedStore, string, T, JsonTypeInfo<T>, TimeSpan, CancellationToken)
Adds a state, as JSON, under a new random key and returns the random part of the key. The state is stored under keyPrefix
followed by the returned value, which the next step of a flow presents.
Declaration
public static ValueTask<string> AddAsync<T>(this IShortLivedStore store, string keyPrefix, T state, JsonTypeInfo<T> typeInfo, TimeSpan lifetime, CancellationToken cancellationToken = default) where T : class
Parameters
| Type | Name | Description |
|---|---|---|
| IShortLivedStore | store | The store. |
| string | keyPrefix | The start of the key, which keeps the states of one flow apart from all others, for example |
| T | state | The state. |
| JsonTypeInfo<T> | typeInfo | The JSON type information of the state. |
| TimeSpan | lifetime | How long the state is kept. Must be positive. |
| CancellationToken | cancellationToken | A token to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<string> | The random part of the key: 256 random bits as 43 URL-safe characters. It cannot be guessed, so it can serve as the secret that a client presents to continue the flow. |
Type Parameters
| Name | Description |
|---|---|
| T |