Scope
Add bounded eviction for in-memory TTL maps.
Problem
Negative cache and related TTL maps use lazy access-only eviction and can retain entries that are never re-queried.
Evidence:
internal/gantry/negcache/negcache.go:115
internal/gantry/negcache/negcache.go:139
internal/gantry/negcache/negcache.go:157
internal/gantry/coldstart/coldstart.go:950-991
internal/gantry/mirror/mirror.go:1716-1744
Changes
- Prefer opportunistic sweeps over background goroutines in library types.
- Add
nextSweep state and sweep expired entries on mutation and occasional lookup.
- Add an optional max-size cap where necessary, evicting the oldest or earliest cooldown deadline first.
- Apply to
negcache.Cache.
- Fire
OnSize after sweeps and mutations.
- Apply the same opportunistic sweep pattern to cold-start
honorUntil and mirror provider-failure maps.
Tests
- Expired entries are removed on a later mutation/lookup even when the same digest is not requested again.
- Size callbacks observe post-sweep counts.
- Max-size cap evicts deterministic entries.
- Fake clock tests cover negcache, cold-start honor windows, and mirror provider-failure maps.
Scope
Add bounded eviction for in-memory TTL maps.
Problem
Negative cache and related TTL maps use lazy access-only eviction and can retain entries that are never re-queried.
Evidence:
internal/gantry/negcache/negcache.go:115internal/gantry/negcache/negcache.go:139internal/gantry/negcache/negcache.go:157internal/gantry/coldstart/coldstart.go:950-991internal/gantry/mirror/mirror.go:1716-1744Changes
nextSweepstate and sweep expired entries on mutation and occasional lookup.negcache.Cache.OnSizeafter sweeps and mutations.honorUntiland mirror provider-failure maps.Tests