Design a key-value store with transactions
The interviewer asks you to design an in-memory store with get, set and delete, plus begin, commit and rollback, which can nest. Picture a family's calendar on the kitchen wall. Each person plans on a pad of sticky notes in their own pocket, and a new plan goes on a new note on top. To check a day, you look at your top note, then the notes under it, then the wall. When you are sure, you take the one pen and copy your notes onto the wall.
It is also asked as "design an in-memory database" or "a key-value store with nested transactions". The closest other case study is the LRU cache, which forgets keys where this keeps them. Interviewers like it because rollback looks easy until a second client reads a value that is later undone. This page is the class-level part. Isolation levels owns the names, and Distributed key-value store owns the store on many machines.
Below is a full 45-minute round on the LLD framework. You are the candidate. At each Guess before you read on, stop and answer first. The full runnable project, with its tests, is a download in Java, JavaScript and Python.
Run the full project
This design as a project you can run, with its tests and a demo. You only need Java 21, Node 24 or Python 3.13. The README says how to run it.
Step 1 · Clarify the requirements and cut the scope
Minutes 0–5 · How this step works
Interviewer: Design a key-value store with transactions.
You: What are the keys and values?
Interviewer: Both are strings, and a missing key reads as nothing.
You: What does it mean for transactions to nest?
Interviewer: An inner commit hands its writes to the outer transaction. An inner rollback undoes only the inner writes.
You: How many clients use it at once?
Interviewer: About 50, each on its own thread, each with its own transactions.
You: How big is it, and is it only ever in memory?
Interviewer: A million keys, in memory for now, and we may want a store on disk later. A transaction makes about 10 writes and usually nests two or three levels deep, with no hard limit.