Table of Contents

Class ApplicationLocalDataCache

Namespace
Arc4u.OAuth2.Token
Assembly
Arc4u.OAuth2.dll

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

cache ISecureCache

The secure cache in which the tokens are persisted.

logger ILogger

The 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

key string

The 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

key string

The unique key of the token.

optionsName string

The name of the TokenCacheOptions to use, or null for the default ones.

cancellationToken CancellationToken

A 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

key string

The unique key.

optionsName string

The name of the TokenCacheOptions to use, or null for the default ones.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

ValueTask<T>

The value, or the default of T when there is none.

Type Parameters

T

The 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

key string

The unique key.

data T

The value to store. A null value is ignored by some implementations.

optionsName string

The name of the TokenCacheOptions to use, or null for the default ones.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

ValueTask

A task that completes when the value is stored.

Type Parameters

T

The type of the value.

Remarks

The optionsName is ignored: there is a single secure cache. Errors are logged.