Table of Contents

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

TKey

Tracker 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

comparer IEqualityComparer<TKey>

Properties

Count

Current number of tracked keys.

public int Count { get; }

Property Value

int

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

nowUtc DateTime

Current UTC timestamp.

maxScan int

Maximum queue nodes to inspect this sweep.

maxRemove int

Maximum 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

key TKey

Tracker key.

nowUtc DateTime

Current UTC timestamp.

duration TimeSpan

Window duration.

Returns

bool

true if allowed now; otherwise false.