Caching easy
Why is 'Cache Invalidation' often cited as one of the hardest problems in Computer Science?
- A Because modern RAM hardware is inherently unreliable and prone to frequent unrecoverable bit-flip errors.
- B Because it requires accurately predicting the future access frequency of every individual item in the dataset.
- C Because maintaining a duplicate copy of data in sync with a rapidly changing source of truth is architecturally complex.
- D Because calculating the optimal eviction score for a given cache entry is a theoretically NP-hard computational problem.
Answer: C. Because maintaining a duplicate copy of data in sync with a rapidly changing source of truth is architecturally complex.
Any copy of data implies potential divergence. Instantaneously updating all copies when the source changes (in a distributed system with failures) is considered an **architectural trade-off** between consistency and availability (CAP theorem). It requires complex strategies (like invalidation, leases, or distinct TTLs) to ensure users don't see dangerously stale data.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- In the Cache-Aside pattern, what happens when the application requests data that is missing from the cache (a 'Cache Miss')?
- Why use a centralized Distributed Cache (like a Redis Cluster) over local in-memory caches on each web server?
- Setting a short TTL (e.g., 60 seconds) on a cached object helps to:
- What is the primary architectural goal of introducing a cache into a system?
- Most caching systems rely on the principle of 'Temporal Locality', which states:
- Your cache uses an LRU (Least Recently Used) eviction policy. When the cache is full, which item is removed?