Class ApplicationLocalDataCache
An ITokenCache for a local client application: the tokens are persisted in the ISecureCache and kept in memory, by key, for the next reads.
[Export(typeof(ITokenCache))]
[Shared]
public class ApplicationLocalDataCache : ITokenCache
- Inheritance
-
ApplicationLocalDataCache
- Implements
- Inherited Members
Constructors
ApplicationLocalDataCache(ISecureCache, ILogger)
Initializes a new instance of the ApplicationLocalDataCache class.
public ApplicationLocalDataCache(ISecureCache cache, ILogger logger)
Parameters
cacheISecureCacheThe secure cache in which the tokens are persisted.
loggerILoggerThe logger.
Methods
Clear(string)
Removes the token from the secure cache and from the in-memory copies. Errors are ignored.
public void Clear(string key)
Parameters
keystringThe key of the token.
DeleteItemAsync(string, string?, CancellationToken)
Delete a token based on its unique key.
public 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.
Remarks
The optionsName is ignored: there is a single secure cache. Errors are ignored.
GetAsync<T>(string, string?, CancellationToken)
Gets a value.
public 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.
Remarks
The optionsName is ignored: there is a single secure cache. The in-memory copy of the key is returned without reading the secure cache;
errors are logged and give null.
PutAsync<T>(string, T, string?, CancellationToken)
Adds or replaces a value.
public 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.
Remarks
The optionsName is ignored: there is a single secure cache. Errors are logged.