Class ExpiringKeyTracker<TKey>
- Namespace
- FishMMO.Server.Core.Collections
- Assembly
- FishMMO.Server.dll
Queue/index tracker for expiring keyed entries. Uses head-first sweeps to avoid full dictionary enumeration under heavy load.
public sealed class ExpiringKeyTracker<TKey>
Type Parameters
TKeyTracker key type.
- Inheritance
-
ExpiringKeyTracker<TKey>
- Inherited Members
Constructors
ExpiringKeyTracker(IEqualityComparer<TKey>)
Initializes a new tracker with an optional key comparer.
public ExpiringKeyTracker(IEqualityComparer<TKey> comparer = null)
Parameters
comparerIEqualityComparer<TKey>
Properties
Count
Current number of tracked keys.
public int Count { get; }
Property Value
Methods
Clear()
Clears all tracked entries.
public void Clear()
Remove(TKey)
Removes a key from the tracker if present. Useful for cancelling a debounce window when the operation it was guarding has already failed and the caller wants to allow an immediate retry rather than make the user wait out the window.
public bool Remove(TKey key)
Parameters
keyTKeyTracker key to remove.
Returns
- bool
trueif the key existed and was removed; otherwisefalse.
SweepExpired(DateTime, int, int)
Sweeps expired keys with bounded scan and removal limits.
public int SweepExpired(DateTime nowUtc, int maxScan, int maxRemove)
Parameters
nowUtcDateTimeCurrent UTC timestamp.
maxScanintMaximum queue nodes to inspect this sweep.
maxRemoveintMaximum keys to remove this sweep.
Returns
- int
Number of entries removed.
TryBegin(TKey, DateTime, TimeSpan)
Attempts to begin a debounce/rate-limit window for a key.
public bool TryBegin(TKey key, DateTime nowUtc, TimeSpan duration)
Parameters
Returns
- bool
trueif allowed now; otherwisefalse.