Implementing redis serialisation protocol

Implementing redis serialisation protocol

Table of contents

No heading

No headings in the article.

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 design a clean interface before writing code. The underlying implementation may change, but a big rewrite will be avoided as long as the interface is still valid. In this case, the interface of these two methods is 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.