Table of Contents

Class CacheHelper

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

Default ICacheHelper: resolves the cache named by CacheName, and falls back to the default cache.

[Export(typeof(ICacheHelper))]
[Shared]
public class CacheHelper : ICacheHelper
Inheritance
CacheHelper
Implements
Inherited Members

Constructors

CacheHelper(ICacheContext, ILogger<CacheHelper>, IOptions<TokenCacheOptions>)

Initializes a new instance of the CacheHelper class.

public CacheHelper(ICacheContext cacheContext, ILogger<CacheHelper> logger, IOptions<TokenCacheOptions> options)

Parameters

cacheContext ICacheContext

The context giving access to the registered caches.

logger ILogger<CacheHelper>

The logger.

options IOptions<TokenCacheOptions>

The token cache options.

Remarks

Only the default TokenCacheOptions are read, once, to resolve the token cache: AddTokenCache fixes them at startup, so IOptions<TOptions> is enough. The named options are resolved by TokenCacheResolver, which needs an IOptionsMonitor<TOptions>.

Methods

GetCache()

Gets the cache used to store the tokens.

public ICache GetCache()

Returns

ICache

The token cache.

GetCache(string?)

Gets the cache registered under cacheName.

public ICache GetCache(string? cacheName)

Parameters

cacheName string

The name of the cache. When it is empty, the token cache (see GetCache()) is returned.

Returns

ICache

The named cache, or the default cache when no cache is registered under cacheName.

Remarks

Each name is resolved once and the cache is kept. When the cache cannot be initialized, the error is logged and the default cache is used, as for the token cache.