Wycademy/src/Wycademy/Commands/Services/CommandCacheService.cs
/// <summary>
/// Adds a new command:response set to the cache.
/// </summary>
/// <param name="key">The ID of the command message.</param>
/// <param name="value">The ID of the response message.</param>
Adds a new command:response set to the cache.
Adds a new command : response set to the cache .
public void Add(ulong key, HashSet<ulong> values)
        {
            if (_cache.Count >= _maxCapacity)
            {
                int itemsToRemove = (_cache.Count - _maxCapacity) + 1;
                var orderedKeys = Keys.OrderBy(k => k >> 22).ToList();
                for (int i = 0; i < itemsToRemove; i++)
                {
                    Remove(orderedKeys[i]);
                }
            }
            _cache.Add(key, values);
        }
public void Add ( ulong key , HashSet < ulong > values ) { if ( _cache . Count >= _maxCapacity ) { int itemsToRemove = ( _cache . Count - _maxCapacity ) + 1 ; var orderedKeys = Keys . OrderBy ( k => k >> 22 ) . ToList ( ) ; for ( int i = 0 ; i < itemsToRemove ; i ++ ) { Remove ( orderedKeys [ i ] ) ; } } _cache . Add ( key , values ) ; }
Adds a new command:response set to the cache.
Adds a new command : response set to the cache .
// Always remove at least one item. // The leftmost 44 bits of an ID represent the timestamp.
key
ulong
The ID of the command message.
The ID of the command message .
values
HashSet<ulong>
value
The ID of the response message.
The ID of the response message .