---
# System prepended metadata

title: Redis Lite Question

---

## Redis Lite

Goal: implement an in-memory key-value database that supports transactions.

Supported methods should include:

- `get(key)` - get value by key
- `set(key, value)` - set value by key
- `delete(key)` - delete key
- `start()` - start a transaction
- `commit()` - commit the current transaction
- `rollback()` - rollback the current transaction

Transactions should be atomic, meaning that if any of the operations in the transaction fails, all operations are rolled back.

You should design the system with concurrency in mind. Transactions should fail if the keys they operate on were modified by other users after those transactions were started but before they were committed. For example:

1. User A calls `start`
2. User A calls `set(x, y)`
3. User B calls `delete(x)`
4. User A calls `commit`

Step (4) should fail because x has been modified since step (2). Note that if User B modified an unrelated key or modified x in between steps (1) and (2), the transaction should succeed.

Use any programming language that you'd like.
