Design a single-node persistent in-memory cache
DatabricksSoftware Engineer · Technical ScreenLast updated
This question evaluates a candidate's skills in single-node cache design, including in-memory key/value storage, eviction policy management (e.g., LRU), durability considerations, concurrency control, and techniques for reducing contention such as sharding or striping.
Scenario
Design a single-machine cache used by a web service to handle read/write requests.
The cache should:
- Store key/value pairs in memory (fast reads)
- Support typical operations:
Get(key),Put(key, value),Delete(key) - Enforce an eviction policy such as LRU when memory capacity is reached
- Optionally provide durability so that after a process crash/restart, the cache can recover its contents
The interviewer expects:
- A concrete design with data structures
- Pseudocode-level APIs and key internal logic
- Discussion of concurrency (locks), minimizing critical sections, avoiding deadlocks
- How to scale on a single machine (e.g., sharding/striping to reduce lock contention)
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.