Build your own Redis

Build your own Redis

Learn about TCP servers, event loops, the Redis protocol and more
Difficulty
Medium
Attempts
324
Supported Languages
Python
Ruby
Go
Rust
C
Haskell
Elixir
PHP
JavaScript
Java

Introduction

In this challenge, you’ll build an application that can speak the Redis protocol, and is capable of serving basic commands like PING, ECHO, SET and GET. Along the way, you’ll learn about TCP servers, event loops and more.

Testimonials

Stages

Bind to a port
#1

In this stage, you’ll start a TCP server on port 6379, which is the default port that Redis uses.

324 completions
Respond to PING
#2

In this stage, you’ll respond to the PING command. You’ll use the Redis protocol to encode the reply.

235 completions
Respond to multiple PINGs
#3

In this stage, you’ll respond to multiple PING commands sent by the same client.

203 completions
Handle concurrent clients
#4

In this stage, you’ll add support for multiple concurrent clients to your Redis server. To achieve this you’ll use an Event Loop, like the official Redis implementation does.

180 completions
Implement the ECHO command
#5

In this stage, you’ll respond to the ECHO command. You’ll parse user input according to the the Redis protocol specification.

115 completions
Implement the SET & GET commands
#6

In this stage, you’ll need to implement the SET & GET commands.

107 completions
Expiry
#7

In this stage, you’ll add support for setting a key with an expiry. The expiry is provided using the “PX” argument to the SET command.

99 completions