Last week, Redis reached a major milestone with the release of 5.0, which includes a variety of advancements and improvements. The big story here is the introduction of Streams as part of the release. Streams is the first entirely new data structure in Redis since HyperLogLog was introduced as part of 2.8.9 back in April 2014 (over four years ago)!
So what is Redis Streams, you may ask? A Redis Stream is a log-like data structure that allows you to store multiple fields and string values with an automatic, time-based sequence at a single key. In many ways, Streams resembles other Redis data structures — it orders data in a manner reminiscent of Lists, it stores fields and values similar to Hashes, it enables you to read ranges of values like you can with Sorted Sets, and it can behave somewhat like Pub/Sub (or Lists) with blocking behavior that waits for items to arrive, allowing for real-time reactions to the stream.
All that said, a Redis Stream is quite distinctly its own thing. It’s not exactly fair to say they are like structure foo but with feature bar. There is a unique capability of Redis Streams that sets it apart from any other existing data structure: consumer groups that allow various clients to consume a stream with their own position. This enables a whole new collection of uses for Redis; tasks like event sourcing or unified log architecture are now not only possible but also optimal. As with any Redis data structure, there are also numerous commands (13, in fact) that allow you to interact with the structure — you can find a list of these commands at redis.io.
With the latest release, sorted sets have now gained a few new commands that allow you to remove the highest- (ZPOPMAX) or lowest- (ZPOPMIN) scoring member of a sorted set. An oft-requested feature, this enables some new patterns that were previously only accessible with Lua scripting.
Accompanying ZPOPMIN and ZPOPMAX are the blocking variants (BZPOPMIN/BZPOPMAX) that wait for a value to arrive, similar to the blocking behavior of lists (BLPOP, as an example). So not only can you now remove the highest or lowest values, but also you can wait for members to arrive.
Aside from new commands and data structures, the 5.0 release includes many refinements to existing internals including:
For a bit of fun, we have also added the useless yet entertaining LOLWUT command, which generates some computer art using random elements and command arguments. It doesn’t have a significant technical purpose, but it might be a nice thing to test to see if Redis 5.0 is running properly when connecting to an instance of an unknown version.
For more details or background on the improvements, you are welcome to take a look at the release notes.
If you’re itching to try Redis 5.0 in Enterprise — especially Streams — you can download Redis Enterprise Software 5.4, which includes Redis 5.0. And you want to run it on our fully managed VPC offering.