Coding Challenge  #37 - Redis CLI Tool

Coding Challenge #37 - Redis CLI Tool

This challenge is to build your own version of the Redis CLI Tool.

When I recently released the course Become a Better Software Developer by Building Your Own Redis Server (Python Edition) I included building a simple version of the Redis CLI tool as one of the lessons and I’ve had some feedback that it would make an interesting challenge on it’s own, so here we are.

BTW, I’m currently porting the course to Go, signup here for the waitlist if you’re interested, everyone on the waitlist will be offered it first at a discount price.

The Challenge - Building A Redis CLI Tool

In this Coding Challenge we’re going to build a CLI tool to send commands to a Redis server, it’s a nice challenge to compliment the build your own Redis challenge. If you’re not familiar with Redis you can learn all about it in that challenge.

Step Zero

In this introductory step your task is to set up your environment up ready to begin developing and testing your solution.

Choose your target platform, set up your editor and programming language of choice. I’d encourage you to pick a tech stack that you’re comfortable doing both network programming (we’re building a tool that is a network client) and test driven development (TDD) with.

Once you’ve done that you might like to?install Redis?itself so you can use it to test your CLI tool implementation against.

Step 1

In this step your goal is to build the functionality to serialise and de-serialise Redis Serialisation Protocol (RESP) messages. This is the protocol used to communicate with a Redis Server. Throughout this step you may wish to refer to the?RESP protocol specification.

Redis uses RESP as a request-response protocol in the following way:

  • Clients send commands to a Redis Server as a RESP Array of Bulk Strings.
  • The server replies with one of the RESP types according to the command implementation.

In RESP, the first byte determines the data type:

  • For?Simple Strings, the first byte of the reply is "+"
  • For?Errors, the first byte of the reply is "``"
  • For?Integers, the first byte of the reply is ":"
  • For?Bulk Strings, the first byte of the reply is "$"
  • For?Arrays, the first byte of the reply is "``"

RESP can represent a Null value using a special variation of Bulk Strings:?"$-1\r\n"?or Array:?"*-1\r\n".

Now that we have the basics of the protocol, your challenge is to write the code required to serialise and de-serialise messages. My personal approach to this would be to use?test-driven development?(TDD) to build tests.

Continued...

You can find Step 2 and beyond on the?Coding Challenges?website as write your own Redis CLI Tool.


Or if you'd rather get the whole challenge delivered to you inbox every week, you can subscribe on the?Coding Challenges Substack.


When you’re ready, there are 4 ways I can help you:


  1. I write another FREE newsletter?Developing Skills?that helps you level up the other skills you need to be a great software developer.
  2. I have a course Become a Better Software Developer by Building Your Own Redis Server (Python Edition) which guides you through solving the Redis Coding Challenge in Python.
  3. I occasionally run a cohort based course:?Coding Challenges Live: Redis Edition!
  4. Promote your business to 72,000+ subscribers by sponsoring this newsletter.



Daniel Moka

I help you master Test-Driven Development (TDD)

10 个月

A new banger challenge just dropped! ?? For CLI tools, I usually use Rust, highly recommend to everyone!

Kyle Piper

Chief Architect @ AppOmni

10 个月

I wish I had someone curating challenges like this for me earlier! Thanks, John.

Rabi Siddique

Software Engineer | JavaScript | Docker | FullStack Developer

10 个月

These challenges are amazing actually. I once built my own Redis and it was an amazing learning journey. Might try building a grep sometime. ??

Neo Kim

Writes System Design Newsletter ? I Teach You System Design

10 个月

loving these challenges, John Crickett. Thanks

要查看或添加评论,请登录

社区洞察

其他会员也浏览了