Skip to main content

Crate chio_bounded

Crate chio_bounded 

Source
Expand description

Reusable bounded in-memory collections for Chio serving processes.

Core invariant: no long-lived collection in a serving process may exist without (1) a capacity policy (ring, LRU, idle-sweep, or deny-at-cap) and (2) a live size metric. This crate is the substrate: Ring and BoundedMap each own a cloneable SizeGauge.

Structs§

BoundedMap
Capacity-bounded, optionally TTL-swept map for caches and rate-limit tables. Eviction order is oldest-insert (approximate LRU: a re-insert of an existing key moves it to newest; get refreshes the idle timestamp but does not reorder). insert returns any (key, value) evicted for capacity so the caller can persist-before-drop. capacity == 0 disables the cache, mirroring Ring.
Ring
Fixed-capacity append-only ring for process-local mirrors. capacity == 0 means “disabled” (stores nothing, hands each item straight back), the correct default when a durable store is authoritative.
SizeGauge
Live entry-count gauge for a bounded structure. Cloneable handle so a telemetry exporter can read the count without locking the structure that owns it.