Class ExpiringKeyTracker<TKey>
- Namespace
- FishMMO.Auth.Core.Collections
- Assembly
- FishMMO-ServerAuth.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()
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.