Class MemoryConfigurationManagerCache
- Namespace
- Auth0.AspNetCore.Authentication.Api.CustomDomains
- Assembly
- Auth0.AspNetCore.Authentication.Api.dll
Default in-memory cache implementation using MemoryCache.
public sealed class MemoryConfigurationManagerCache : IConfigurationManagerCache, IDisposable
- Inheritance
-
MemoryConfigurationManagerCache
- Implements
- Inherited Members
Remarks
Default cache used when no custom IConfigurationManagerCache is provided. Supports configurable size limits and sliding expiration.
Constructors
MemoryConfigurationManagerCache(int, TimeSpan?, ILogger<MemoryConfigurationManagerCache>?)
Initializes a new instance of the MemoryConfigurationManagerCache class.
public MemoryConfigurationManagerCache(int maxSize = 100, TimeSpan? slidingExpiration = null, ILogger<MemoryConfigurationManagerCache>? logger = null)
Parameters
maxSizeintMaximum number of configuration managers to cache. Default is 100.
slidingExpirationTimeSpan?Optional sliding expiration for cached entries. When set, entries that haven't been accessed within this duration will be removed on the next cache operation.
loggerILogger<MemoryConfigurationManagerCache>Optional logger for logging cache operations and disposal errors.
Exceptions
- ArgumentOutOfRangeException
Thrown when maxSize is less than 1.
Methods
Clear()
Clears all cached entries.
public void Clear()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetOrCreate(string, Func<string, IConfigurationManager<OpenIdConnectConfiguration>>)
Gets an existing configuration manager from the cache or creates a new one using the factory.
public IConfigurationManager<OpenIdConnectConfiguration> GetOrCreate(string metadataAddress, Func<string, IConfigurationManager<OpenIdConnectConfiguration>> factory)
Parameters
metadataAddressstringThe OIDC metadata endpoint URL, used as the cache key.
factoryFunc<string, IConfigurationManager<OpenIdConnectConfiguration>>Factory function to create a new configuration manager if not cached.
Returns
- IConfigurationManager<OpenIdConnectConfiguration>
The cached or newly created configuration manager.