Katkat

Design a single-node persistent in-memory cache

DatabricksSoftware Engineer · Technical Screen

Last 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)