Redis 5.0 Featured Image

Redis 5.0 is here!

by Kyle Davis

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)!

Streams

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.

ZPOP and friends

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.

Other improvements

Aside from new commands and data structures, the 5.0 release includes many refinements to existing internals including:

  • New Modules API capabilities
  • Improvements in HyperLogLog implementation
  • HELP for many sub-commands
  • Enhancements to memory management and reporting
  • RDB storing frequency and recency information about keys (i.e. LFU, LRU)
  • Lua replica and AOF refinements
  • Networking and client connection management improvements
  • Client identification and blocking management between clients

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.

 

 

Art inside a database command

(From LOLWUT: a piece of art inside a database command)

For more details or background on the improvements, you are welcome to take a look at the release notes.

Redis Enterprise

We’re in the process of integrating Redis 5.0 within our Redis Enterprise package and Cloud environments, but we will be releasing it shortly, so make sure to look out for that announcement. In the meantime, if you’re itching to try Redis 5.0 in Enterprise — especially Streams — you can download Redis Enterprise Software 5.3 Tech Preview, which includes an earlier release candidate of Redis 5.0. And you want to run this preview on our fully managed VPC offering, just let us know at support@redislabs.com.

Happy Streaming!