Class CacheHelper
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
cacheContextICacheContextThe context giving access to the registered caches.
loggerILogger<CacheHelper>The logger.
optionsIOptions<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
cacheNamestringThe 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.