Step 3 - Challenge: SET and GET
Step 3 - Challenge: SET and GET
Build Your Own Redis Server (Python Edition)
Step 1 - Introduction to RESP, Building a Protocol Handler Using Test-Driven Development
Step 1 - Introduction to RESP, Building a Protocol Handler Using Test-Driven Development
Step 2 - Creating a Network Client and Server
Step 2 - Creating a Network Client and Server
Step 4 - Handling Concurrency
Step 4 - Handling Concurrency
Step 5 - Implementing Expiry
Step 5 - Implementing Expiry
In this step your goal is to set and get the value of a key. You’re going to implement the core functionality of Redis.
To set a key in Redis we use the command SET. For this step we’re just going to implement the simplest version, i.e.:
% redis-cli set Name John
OKWe’ll ignore all the expiry options that Redis supports for now. Once a key has been set you’ll want to implement and test the related command GET.
% redis-cli get Name
"John"When you are implementing the commands don’t forget to read the specification for each command to check that you are returning the correct results to the client and that the results are correctly serialised according to the RESP protocol.
You might also like to use the Redis client library to build some automated tests for your server.
Don’t forget to test edge/error cases as well as the happy path.