Rebuilding Redis in Ruby

2 min read Original article ↗

This chapter will cover the creation of a TCP server in ruby, as well as how to interact with it with netcat, a utility bundled with macOS and linux. We will briefly look at concurrency and parallelism and how threads can impact the behavior of our server.

In this chapter, we’ll build on the foundations we established in the previous chapter. We now know how to start a TCP server using the built-in TCPServer class. In this chapter we’ll build a basic client using another built-in class, TCPSocket. We’ll then make the server actually usable by making it respond to two commands, GET and SET.”

In this chapter we will add support for efficient handling of multiple clients connected simultaneously. We will first isolate the problematic elements of the current implementation and explore different solutions before getting to the final one using the select syscall

In this chapter we add the missing features to the SET command we implemented in chapter 2, EX, PX, NX, XX & KEEPTTL

In this chapter we will focus on making RedisServer speak the Redis Protocol, RESP. Doing so will allow us to use Redis’ built-in client, redis-cli to communicate with our own server.

Liked what you read? Consider subscribing to stay updated!

And if you feel extra generous, consider donating!

Buy me a coffee Buy me a coffee