Interface ITokenCache
A store for the tokens of the current user.
public interface ITokenCache
Remarks
Each method accepts an optional optionsName: the name of the named TokenCacheOptions that selects the cache
and the expiration to use. When it is null, the default TokenCacheOptions (registered by AddTokenCache) are used.
Implementations that have a single store ignore it.
The methods are asynchronous because the store is usually a distributed cache (Redis, SQL Server): a call must not block a thread during the round trip.
Methods
DeleteItemAsync(string, string?, CancellationToken)
Delete a token based on its unique key.
ValueTask DeleteItemAsync(string key, string? optionsName = null, CancellationToken cancellationToken = default)
Parameters
keystringThe unique key of the token.
optionsNamestringThe name of the TokenCacheOptions to use, or null for the default ones.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- ValueTask
A task that completes when the entry is removed.
GetAsync<T>(string, string?, CancellationToken)
Gets a value.
ValueTask<T?> GetAsync<T>(string key, string? optionsName = null, CancellationToken cancellationToken = default)
Parameters
keystringThe unique key.
optionsNamestringThe name of the TokenCacheOptions to use, or null for the default ones.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- ValueTask<T>
The value, or the default of
Twhen there is none.
Type Parameters
TThe type of the value.
PutAsync<T>(string, T, string?, CancellationToken)
Adds or replaces a value.
ValueTask PutAsync<T>(string key, T data, string? optionsName = null, CancellationToken cancellationToken = default)
Parameters
keystringThe unique key.
dataTThe value to store. A null value is ignored by some implementations.
optionsNamestringThe name of the TokenCacheOptions to use, or null for the default ones.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- ValueTask
A task that completes when the value is stored.
Type Parameters
TThe type of the value.