LRU, LFU and What Actually Hits
In short: an LRU (least-recently-used) cache keeps a doubly-linked list in recency order, plus a hash map from key to its node, so every operation is O(1): a hit splices its node to the front (MRU end), a miss evicts the tail (LRU end) and inserts the new key at the front. LFU (least-frequently-used) evicts by hit count instead of recency, breaking ties by recency. Neither is free: LRU can be worse than plain FIFO on some access patterns, because promoting a hit to the front pushes some other key closer to eviction — a key that FIFO, which never reorders on a hit, would have kept.

LRU can lose to a policy that doesn't even look
Quarry compares two eviction policies on the exact same trace: LRU, and plain FIFO (evict whatever arrived first — no reordering on a hit at all):
FIFO gets 2 hits; LRU gets only 1. Trace it: after 2, 3, both
policies hold {2, 3}. The third touch, 2, is a hit for both — but LRU
promotes 2 to the front, which makes 3 the new least-recently-used.
When 1 arrives next (a miss for both), LRU evicts 3 — the exact key 1's
successor, 3 again, needs a step later. FIFO never reordered on the hit, so
it evicts 2 (the oldest insertion) instead, and 3 survives to be a hit.
Reacting to a hit is not automatically the safer choice.