Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

02: RESP parser

The server now speaks the real Redis wire format (RESP). You can connect with redis-cli and it will work.

Why RESP

Once the server understands RESP, every Redis client in the world can talk to it. redis-cli, redis-py, the Go and Java drivers — they all send RESP. That compatibility is huge.

Run it

make 02-resp-parser

In another terminal:

redis-cli -p 6380 PING       # -> PONG
redis-cli -p 6380 SET foo hi # -> "['SET', 'foo', 'hi']"  (just echoes for now)

If you don't have redis-cli, the parser still works over nc — you just have to type the raw RESP bytes:

printf '*1\r\n$4\r\nPING\r\n' | nc localhost 6380
# -> +PONG

What to observe

  • The server logs every parsed command as a Python list
  • PING already returns PONG (simple string) — that's the only command we've wired so far
  • Commands like SET foo hi come back as bulk strings showing the parsed shape

Files

File Purpose
server.py RESP parser + RESP encoder + minimal command dispatch
GUIDE.md The RESP grammar from scratch
EXERCISES.md Hand-write RESP frames, handle partial reads

What's next

Step 3 wires up a real in-memory dict so SET foo hi actually stores hi and GET foo returns it.