Class TokenCacheResolver
Resolves the cache and the MaxTime of the default or named TokenCacheOptions.
It is used by ApplicationCache and by the token providers that use the ICache directly.
It is registered as a singleton by AddTokenCache.
[Export(typeof(TokenCacheResolver))]
[Shared]
public sealed class TokenCacheResolver
- Inheritance
-
TokenCacheResolver
- Inherited Members
Remarks
A name is used only when options are registered under it: by AddNamedTokenCache, AddSharedTokenCache, AddClientTokens or AddOnBehalfOf,
with services.Configure<TokenCacheOptions>(name, …) (an action or a configuration section), or by any other registration (for example
AddOptions<TokenCacheOptions>(name).BindConfiguration(path)) that gives a CacheName or a MaxTime
other than those of a name that is not registered (the class defaults, changed by ConfigureAll or PostConfigureAll when there are some).
Any other name, for example a typo, would give a new TokenCacheOptions with these values: a warning is logged once and the default options are used instead.
Constructors
TokenCacheResolver(ICacheHelper, IOptionsMonitor<TokenCacheOptions>, IEnumerable<IConfigureOptions<TokenCacheOptions>>, ILogger<TokenCacheResolver>)
Initializes a new instance of the TokenCacheResolver class.
public TokenCacheResolver(ICacheHelper cacheHelper, IOptionsMonitor<TokenCacheOptions> options, IEnumerable<IConfigureOptions<TokenCacheOptions>> configureOptions, ILogger<TokenCacheResolver> logger)
Parameters
cacheHelperICacheHelperGives access to the caches.
optionsIOptionsMonitor<TokenCacheOptions>The default and named token cache options.
configureOptionsIEnumerable<IConfigureOptions<TokenCacheOptions>>The registered configurations of the TokenCacheOptions, used to know which names are registered.
loggerILogger<TokenCacheResolver>Logs a warning, once, for each name under which no options are registered.
Methods
Resolve(string?)
Resolves the cache and the maximum time of the named options.
public ResolvedTokenCache Resolve(string? optionsName)
Parameters
optionsNamestringThe name of the TokenCacheOptions, or null for the default ones.
Returns
- ResolvedTokenCache
The cache and its maximum time. The default options are used when no options are registered under
optionsName.