A race condition is a correctness failure in which results depend on the timing or ordering of concurrent operations. In an LRU cache, concurrent reads, writes, eviction, and access-order updates can produce stale reads or data corruption. section 6.4
Interview-ready mitigation strategies include:
- Coarse-grained locking simplifies synchronization but can increase contention. section 6.4
- Fine-grained locking, lock-free data structures, segmented LRU, and sharded caches offer alternative contention and synchronization trade-offs. section 6.4
- Sharding isolates keyspace management across cache instances, reducing contention while allowing Redis fallback for global consistency. section 6.4
LRU eviction under concurrent access
One thread may evict a key while another updates that key’s position in the usage list. Reasoning about this interleaving exposes why the cache needs synchronization. section 6.4
























