Caching easy
Your cache uses an LRU (Least Recently Used) eviction policy. When the cache is full, which item is removed?
- A The item with the absolute oldest insertion timestamp, regardless of recent usage profile.
- B The item that has not been successfully accessed for the longest rolling period of time.
- C The item that has been accessed the fewest number of times total across its entire duration.
- D The largest individual item in terms of total memory footprint to maximize space reclamation.
Answer: B. The item that has not been successfully accessed for the longest rolling period of time.
**LRU (Least Recently Used)** eviction tracks the *time of last access*. When the cache is full, it discards the item that hasn't been used for the longest time, assuming that recently used items are more likely to be used again (temporal locality). This differs from FIFO (First-In-First-Out) or LFU (Least Frequently Used).
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:
- Redis and Memcached store data in RAM. What is the primary implication of this for system design?