mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
Extends the v1.4.33 Coach snapshot LRU shape into a reusable ServerCache<T> with TTL expiry, capacity-bounded LRU eviction, single-flight read coalescing, prefix delete, and per-instance hit/miss/eviction/stampede counters. Adds five invalidation helpers keyed by the per-user prefix scheme so write endpoints can flush every cache that may reflect their changed rows in a single call. The cached() wrapper attaches cache.<name>.outcome + cache.<name>.key_hash to the active wide event so production logs carry the hit ratio without leaking the userId portion of the cache key. Hand-rolled to keep the dependency surface at zero — same recipe as the snapshot cache the dashboard already relies on. Process-local; multi- instance staleness is bounded by TTL, the Redis migration path stays a future option.