Use LRU eviction for evaluation cache instead of FIFO#22
Conversation
On cache hit, move the entry to the end of Map iteration order so recently accessed entries survive eviction. Adds a test verifying the oldest-but-recently-accessed entry is kept while the true LRU entry is evicted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Source? That literally never happens on X.com. |
variants of the same post, not exactly the same. happens frequently during large events- Iran, Anthropic Mythos |
LRU Cache would have to be an exact match -> variant perf wouldn't be improved |
Summary
Mapiteration orderProblem: Trending/viral posts appear repeatedly in feeds. Under FIFO, a post seen 50 times gets evicted just because 500 other posts came after it, forcing a redundant LLM call next time the user scrolls past it.
Fix: 3 lines —
delete+seton cache hit promotes the entry. JavaScriptMappreserves insertion order, so this is a clean O(1) LRU without any new data structures.Test plan