PRO

Effect Segmented LRU Cache

The eviction policy that survives a table scan. A plain LRU treats a one-touch batch job like real traffic, so a single sequential scan marches every hot key out of the cache and the next minute is all misses. Segmented LRU admits new keys to a probation segment and only promotes to protected on a second hit, so scan keys live and die in probation without displacing anything hot, while quiet protected keys demote back so squatters age out. The demo plays a 100-key scan against 4 twice-touched hot keys: plain LRU loses all 4, segmented LRU keeps all 4. Pinned to effect 4.0.0-beta.98.

Install
npx shadcn@latest add @compronents/effect-lru-cache-eviction

Installs from ui.aryank.space. Needs a registry token and a one-time @compronents entry in components.json. The docs walk through both.

Visualization
policy
4 hot keys
Map<string, Entry>
scan (100 cold)
Map<string, Entry>
lru.set(scanKey) // evicts a hot key behind it

A 100-key batch scan marches every hot key out of a plain LRU. One-touch cold keys are treated exactly like real traffic, so the next minute is all misses.

Files
Checking access…
Dependencies