The server is now a real (tiny) Redis. It stores keys and values in memory and answers the most common Redis commands.
make 03-get-setIn another terminal:
redis-cli -p 6380
> SET name Param
OK
> GET name
"Param"
> EXISTS name
(integer) 1
> DEL name
(integer) 1
> GET name
(nil)
> KEYS *
(empty array)| Component | Purpose |
|---|---|
STORE |
Module-level dict that holds every key |
COMMANDS |
Name -> handler function map |
cmd_set, cmd_get, etc. |
Per-command handlers returning encoded RESP |
Each handler takes the list of arguments (already parsed) and returns the encoded reply bytes.
- No expiry (every key lives forever) → step 4
- No persistence (restart loses everything) → step 5
- No pub/sub, no replication → steps 7, 8
| File | Purpose |
|---|---|
server.py |
RESP parser + KV store + command dispatch |
GUIDE.md |
Why a flat dispatch table beats if/elif chains |
EXERCISES.md |
Add INCR, APPEND, MGET; handle large values |
Step 4 adds expiry: SET foo hello EX 10 stores foo for 10 seconds, then it disappears.