BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Redis 5.0 Released with New "Streams" Data Type

Redis 5.0 Released with New "Streams" Data Type

This item in japanese

Bookmarks

Redis recently announced version 5 of its popular database, 15 months after the release of Redis 4. The headline feature of this version is the support for a new data type, "Streams", an append-only data structure which can be used for purposes like log processing using co-operative clients within consumer groups. The Streams implementation is based on Rax, a radix-tree library.

Streams support fast lookups and range queries which are useful building blocks for chat systems, message brokers, queueing systems and most systems that can benefit from the unified log pattern. Streams are similar in concept to Apache Kafka's message passing in their support of consumer groups, but also unique in nature. Streams also support message persistence and master/replica replication functionality. Originally planned for version 4, this data type is now available in version 5 along with extensive documentation.

Sorted set functionality has also improved in Redis 5, with the addition of new commands to pop elements from the start and end of sorted sets. ZPOPMAX / BZPOPMAX will return and remove the element with the highest score in a non-blocking and blocking fashion respectively. Similarly, ZPOPMIN / BZPOPMIN will return and remove elements with the lowest score. Using these commands a developer can simulate list functionality using sorted sets.

Redis modules have also been expanded in the newest version, with the introduction of Clusters and Timers APIs. The Timers API allows modules to create timers with precision duration down to milliseconds and a callback function. The Clusters API (not to be confused with Redis clustering of servers) provides an abstraction for implementing a clustered message bus. This allows a node to send messages to a particular node or all nodes, similar to a pub/sub system.

Several performance improvements under the hood like improved active memory defragmentation and an improved algorithm for HyperLogLog are also included in this release. Most commands now support quick command line HELP using "<command_name> HELP" on the cli, e.g. XINFO HELP for help on the new streams functionality.

The LOLWUT command was also added, which is more of an easter egg than technologically useful to Redis users, as LOLWUT will generate a random variation of computer art, Schotter by Georg Nees. LOLWUT was born out of the need to spend some technologically useless time in order to explore something of the 60s, an era in which the author believes that it was easier to "talk about technology with a hacking perspective, where there are no walls or pre-cooked ideas, and the limit is the exploration."

Finally, the newest Redis version also removed usage of the word "slave", replacing it with "replica", except for any cases that it's required for backwards compatibility.

Rate this Article

Adoption
Style

BT