PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Cursor

Design an In-Memory Transactional Key-Value Store

Last updated: Jul 2, 2026

Quick Overview

This Cursor software engineering question evaluates how a candidate designs a transactional in-memory key-value store with clear API semantics. It is useful preparation for interviews that probe data modeling, rollback behavior, edge cases, and implementation trade-offs without requiring a full distributed system design.

  • medium
  • Cursor
  • Software Engineering Fundamentals
  • Software Engineer

Design an In-Memory Transactional Key-Value Store

Company: Cursor

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

Design an in-memory key-value database that supports transactional reads and writes. Expose a class with these operations: - `begin()` starts a transaction and returns a transaction id. - `get(txid, key)` reads the value visible to that transaction. - `set(txid, key, value)` writes a value inside that transaction. - `commit(txid)` attempts to make the transaction's writes visible. - `rollback(txid)` discards the transaction's writes. The interviewer is especially interested in how your design handles conflicting concurrent writes to the same key, and read/write races where two transactions observe stale values and then swap values between keys. ### Constraints & Assumptions - The database is in memory only; durability and crash recovery are out of scope unless the interviewer asks. - Keys and values can be treated as strings. - Transaction ids are generated by the database. - A transaction should read its own writes. - You may choose optimistic or pessimistic concurrency control, but you must explain the trade-offs. ### Clarifying Questions to Ask - Should transactions provide serializable isolation, snapshot isolation, or a weaker guarantee? - Can two transactions write the same key concurrently, or should the second writer block or fail? - Should `commit` return a success/failure result, raise an error, or retry automatically? - Are long-running transactions common, and is starvation acceptable? - Do we need nested transactions, deletes, TTLs, or range scans? ### What a Strong Answer Covers ```premium-lock What a Strong Answer Covers ``` ### Follow-up Questions - How would your design change if `get` outside a transaction must also be supported? - How would you add deletes? - How would you prevent a long transaction from making validation expensive? - How would you test the two-key swap race? - What would need to change to make the database durable?

Quick Answer: This Cursor software engineering question evaluates how a candidate designs a transactional in-memory key-value store with clear API semantics. It is useful preparation for interviews that probe data modeling, rollback behavior, edge cases, and implementation trade-offs without requiring a full distributed system design.

Related Interview Questions

  • Build a Streaming Markdown Code Fence Parser - Cursor (hard)
  • Implement a Merkle Tree for Repository Contents - Cursor (medium)
|Home/Software Engineering Fundamentals/Cursor

Design an In-Memory Transactional Key-Value Store

Cursor logo
Cursor
Jul 2, 2026, 6:55 PM
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
8
0

Design an in-memory key-value database that supports transactional reads and writes.

Expose a class with these operations:

  • begin() starts a transaction and returns a transaction id.
  • get(txid, key) reads the value visible to that transaction.
  • set(txid, key, value) writes a value inside that transaction.
  • commit(txid) attempts to make the transaction's writes visible.
  • rollback(txid) discards the transaction's writes.

The interviewer is especially interested in how your design handles conflicting concurrent writes to the same key, and read/write races where two transactions observe stale values and then swap values between keys.

Constraints & Assumptions

  • The database is in memory only; durability and crash recovery are out of scope unless the interviewer asks.
  • Keys and values can be treated as strings.
  • Transaction ids are generated by the database.
  • A transaction should read its own writes.
  • You may choose optimistic or pessimistic concurrency control, but you must explain the trade-offs.

Clarifying Questions to Ask

  • Should transactions provide serializable isolation, snapshot isolation, or a weaker guarantee?
  • Can two transactions write the same key concurrently, or should the second writer block or fail?
  • Should commit return a success/failure result, raise an error, or retry automatically?
  • Are long-running transactions common, and is starvation acceptable?
  • Do we need nested transactions, deletes, TTLs, or range scans?

What a Strong Answer Covers Premium

Follow-up Questions

  • How would your design change if get outside a transaction must also be supported?
  • How would you add deletes?
  • How would you prevent a long transaction from making validation expensive?
  • How would you test the two-key swap race?
  • What would need to change to make the database durable?
Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Cursor•More Software Engineer•Cursor Software Engineer•Cursor Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.