Yap Han Chiang
A techie's ramblings

A techie's ramblings

Implementing redis serialisation protocol

Implementing redis serialisation protocol

Yap Han Chiang's photo
Yap Han Chiang
·May 29, 2022·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

This is a follow-up post from Building redis with CodeCrafters.

When I first started the redis challenge, I did the quick and dirty way of bypassing the redis serialisation protocol in order to make things work.

Redis serialisation protocol implementation

In the next release, I implemented the redis serialisation protocol, which can handle a few data types: simple string, bulk string, error, integer, array.

It was a great exercise that puts recursion into practice. Working with raw bytes is much more performant than converting them to string every time.

Integrate redis serialisation protocol

Next up is to integrate the parser with the codebase. There was quite a bit of code because the older method of parsing input is totally different from this new implementation.

This shows the importance of having a clean interface before writing code. The underlying implementation may change, but a big rewrite will be avoided as long as the interface is robust. However, in this case the interface of these two methods are completely different, resulting in a breaking change in the parser.

Finally, examples of usage are updated to be clearer and user friendly

Check it out here.

 
Share this