src/Microsoft.IdentityModel.Tokens/EventBasedLRUCache.cs
/// <summary>
/// Remove all expired cache items from _doubleLinkedList and _map.
/// </summary>
/// <returns>Number of items removed.</returns>
Remove all expired cache items from _doubleLinkedList and _map.
Remove all expired cache items from _doubleLinkedList and _map .
internal int RemoveExpiredValuesLRU()
        {
            int numItemsRemoved = 0;
            try
            {
                var node = _doubleLinkedList.First;
                while (node != null)
                {
                    var nextNode = node.Next;
                    if (node.Value.ExpirationTime < DateTime.UtcNow)
                    {
                        _doubleLinkedList.Remove(node);
                        if (_map.TryRemove(node.Value.Key, out var cacheItem))
                            OnItemRemoved?.Invoke(cacheItem.Value);
                        numItemsRemoved++;
                    }
                    node = nextNode;
                }
            }
            catch (ObjectDisposedException ex)
            {
                LogHelper.LogWarning(LogHelper.FormatInvariant(LogMessages.IDX10902, LogHelper.MarkAsNonPII(nameof(RemoveExpiredValuesLRU)), ex));
            }
            return numItemsRemoved;
        }
internal int RemoveExpiredValuesLRU ( ) { int numItemsRemoved = 0 ; try { var node = _doubleLinkedList . First ; while ( node != null ) { var nextNode = node . Next ; if ( node . Value . ExpirationTime < DateTime . UtcNow ) { _doubleLinkedList . Remove ( node ) ; if ( _map . TryRemove ( node . Value . Key , out var cacheItem ) ) OnItemRemoved ? . Invoke ( cacheItem . Value ) ; numItemsRemoved ++ ; } node = nextNode ; } } catch ( ObjectDisposedException ex ) { LogHelper . LogWarning ( LogHelper . FormatInvariant ( LogMessages . IDX10902 , LogHelper . MarkAsNonPII ( nameof ( RemoveExpiredValuesLRU ) ) , ex ) ) ; } return numItemsRemoved ; }
Remove all expired cache items from _doubleLinkedList and _map.
Remove all expired cache items from _doubleLinkedList and _map .
Number of items removed.
Number of items removed .