Documentation
¶
Overview ¶
Package bounded provides a size-bounded, TTL-aware key→value map for the gateway's per-instance affinity records and its in-process shared-state store.
The stores built on it are all keyed by identifiers the gateway does not choose and cannot bound — upstream resource URIs, upstream-minted task ids, verified principal identities — so an ordinary map is a slow leak a busy federation drives on its own. Eviction is safe at every call site: each falls back to a path that already handles an unknown key (a resource or task probe, a freshly built limiter).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[V any] struct { // contains filtered or unexported fields }
Map is a bounded key→value map with per-entry expiry.
The bound is generational rather than LRU: when the live generation fills, it becomes the previous generation and a fresh one starts. Reads check both and promote what they find, so a key in use survives a rotation and only keys untouched for a full generation are dropped. Every operation is O(1) with no ordering bookkeeping, at a resident cost of at most 2×max entries.
func (*Map[V]) Len ¶
Len reports the number of resident records across both generations, including any not yet reclaimed by a read.
func (*Map[V]) Load ¶
Load returns the value for key. A hit in the previous generation is promoted into the live one, so an in-use key is not dropped by the next rotation. An expired entry reads as absent and is dropped.
func (*Map[V]) LoadOrStore ¶
LoadOrStore returns the existing live value for key, or stores and returns value when there is none. loaded reports which happened.