It’s not everywhere, but at this point a lot of folks have used Redis. It supports a broad array of data structures like lists, hashes, hyperloglog and even pub/sub. It’s remarkably high throughput, while also being single-threaded so you don’t have any weird concurrency-related behaviors to debug.
Every line is terminated by \r\n. Clients start each command with a line in the format of *3, which declares the command will have three parameters. Each parameter is two lines, where the first line starts with $ followed by an integer, which declares the number of bytes in the following line, excluding the terminating \r\n.
The server responds concisely:
It worked! +OK\r\n is the positive confirmation message for all successful operations that don’t have a return value. If it had been an error, for example if we’d tried to call incr on a string value, it will return an error in format:
-ERR value is not an integer or out of range\r\n
Now, let’s retrieve that value:
# returns 'hello'
The client sends:
The server responds with:
There are so many things I love about this protocol!
It’s simple enough that you can implement a simple client or server implementation in an hour or two!
It’s human readable!
The declared line count and line lengths mean you don’t have to parse the contents!