Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

03: GET/SET

The server is now a real (tiny) Redis. It stores keys and values in memory and answers the most common Redis commands.

Run it

make 03-get-set

In 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)

What's new

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.

What you don't have yet

  • No expiry (every key lives forever) → step 4
  • No persistence (restart loses everything) → step 5
  • No pub/sub, no replication → steps 7, 8

Files

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

What's next

Step 4 adds expiry: SET foo hello EX 10 stores foo for 10 seconds, then it disappears.