Back to Arcade questions
CodingSoftware Engineer

Key-Value Store with Transactions

Frequency: Reported


Implement a key-value store with transactions in Python.

Required store API

Implement this high-level API:

python
# Initialization
store = new Store(<anything>)

# Data manipulation
store.set(K, V)
store.get(K)
store.delete(K)

# Transactions
store.begin()     # begins the transaction
store.commit()    # commits the transaction
store.rollback()  # rolls the transaction back

Implement tests for the API.

Implement a REST API layer over the key-value API using Django REST Framework or Flask. SQLite or Postgres may be used to make the store persistent.

Optional extensions

  • Add any additional public methods that would be useful to a user of the store.
  • Implement the core key-value API with asyncio to support concurrent transactions.

The prompt gave this nested-transaction example:

python
store.begin()
store.set("a", 50)
store.begin()
store.set("a", 60)

Submission and follow-up

  • Submit the project as a ZIP file or GitHub repository.
  • Include a short README explaining how to run the project.
  • Be ready to walk through the implementation in an IDE and pair with an onsite interviewer to add features or improvements.