Table of Contents

Namespace FishMMO.Server.Core.Collections

Classes

ExpiringKeyTracker<TKey>

Queue/index tracker for expiring keyed entries. Uses head-first sweeps to avoid full dictionary enumeration under heavy load.

LastSeenCacheTracker<TKey, TValue>

Queue/index tracker for key-value caches whose entries expire by last-seen timestamp. Optimized for high-frequency touch and bounded head-first TTL sweeps.

SingleFlightCache<TKey, TValue>

A thread-safe, fixed-TTL cache of asynchronous reads in which every caller asking for the same key while a read is in flight shares that one read.

TimedCache<TKey, TValue>

A thread-safe, write-through TTL cache where entries expire after a fixed duration from when they were stored. Reads do NOT extend the lifetime (unlike LastSeenCacheTracker<TKey, TValue>).

Supports bounded head-first SweepExpired(TimeSpan, int, int) for memory management.

Ages are measured on MonotonicClock, not the host's wall clock. A TTL is a duration, and on DateTime.UtcNow a clock stepped back an hour kept every entry "fresh" for that hour: the world server's available-scene cache served the same instance list, populations and all, long after the instances had filled or gone.

Structs

InstanceCapacityHeap

A max-heap of scene instances, keyed by scene row ID, ordered by remaining capacity. Used for O(log N) fallback instance selection in open-world routing.

The root always holds the instance with the most remaining capacity. TryAssignFromTop(out long) peeks the root, decrements its capacity, and re-heapifies — yielding O(log N) per assignment instead of O(N) linear scan. If the root reaches zero capacity it is removed automatically.