src/Microsoft.IdentityModel.Tokens/EventBasedLRUCache.cs
/// <summary>
/// Remove all expired cache items from the _map ONLY. This is called for the non-LRU (_maintainLRU = false) scenaro.
/// The enumerator returned from the dictionary is safe to use concurrently with reads and writes to the dictionary, according to the MS document.
/// </summary>
/// <returns>Number of items removed.</returns>
Remove all expired cache items from the _map ONLY. This is called for the non-LRU (_maintainLRU = false) scenaro.
The enumerator returned from the dictionary is safe to use concurrently with reads and writes to the dictionary, according to the MS document.
Remove all expired cache items from the _map ONLY . This is called for the non - LRU ( _maintainLRU = false ) scenaro . The enumerator returned from the dictionary is safe to use concurrently with reads and writes to the dictionary according to the MS document .
internal int RemoveExpiredValues()
        {
            int numItemsRemoved = 0;
            try
            {
                foreach (var node in _map)
                {
                    if (node.Value.ExpirationTime < DateTime.UtcNow)
                    {
                        if (_map.TryRemove(node.Value.Key, out var cacheItem))
                            OnItemRemoved?.Invoke(cacheItem.Value);
                        numItemsRemoved++;
                    }
                }
            }
            catch (ObjectDisposedException ex)
            {
                LogHelper.LogWarning(LogHelper.FormatInvariant(LogMessages.IDX10902, LogHelper.MarkAsNonPII(nameof(RemoveExpiredValues)), ex));
            }
            return numItemsRemoved;
        }
internal int RemoveExpiredValues ( ) { int numItemsRemoved = 0 ; try { foreach ( var node in _map ) { if ( node . Value . ExpirationTime < DateTime . UtcNow ) { if ( _map . TryRemove ( node . Value . Key , out var cacheItem ) ) OnItemRemoved ? . Invoke ( cacheItem . Value ) ; numItemsRemoved ++ ; } } } catch ( ObjectDisposedException ex ) { LogHelper . LogWarning ( LogHelper . FormatInvariant ( LogMessages . IDX10902 , LogHelper . MarkAsNonPII ( nameof ( RemoveExpiredValues ) ) , ex ) ) ; } return numItemsRemoved ; }
Remove all expired cache items from the _map ONLY.
Remove all expired cache items from the _map ONLY .
Number of items removed.
Number of items removed .