<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.16.0" />

Microsoft.IdentityModel.Tokens.EventBasedLRUCache<TKey, TValue>

class EventBasedLRUCache<TKey, TValue>
This is an LRU cache implementation that relies on an event queue rather than locking to achieve thread safety. This approach has been decided on in order to optimize the performance of the get and set operations on the cache. This cache contains a doubly linked list in order to maintain LRU order, as well as a dictionary (map) to keep track of keys and expiration times. The linked list (a structure which is not thread-safe) is NEVER modified directly inside an API call (e.g. get, set, remove); it is only ever modified sequentially by a background thread. On the other hand, the map is a ConcurrentDictionary<T, U> which may be modified directly inside an API call or through eventual processing of the event queue. This implementation relies on the principle of 'eventual consistency': though the map and it's corresponding linked list may be out of sync at any given point in time, they will eventually line up. See here for more details: https://aka.ms/identitymodel/caching
protected int CalculateNewCacheSize()

When the cache is at _maxCapacityPercentage, it needs to be compacted by _compactionPercentage. This method calculates the new size of the cache after being compacted.

public bool Contains(TKey key)

public void SetValue(TKey key, TValue value)

public bool SetValue(TKey key, TValue value, DateTime expirationTime)

public bool TryGetValue(TKey key, out TValue value)

public bool TryRemove(TKey key)

public bool TryRemove(TKey key, out TValue value)