DCS Redis Help Documentation

New Features of Redis 5.0

2024-05-25 02:00:33

Official Reference: https://redis.com/blog/redis-5-0-is-here/

Stream

For details, see the official documentation: https://redis.io/docs/data-types/streams/

A Redis stream is a data structure that acts like an append-only log but also implements several operations to overcome some of the limits of a typical append-only log. These include random access in O(1) time and complex consumption strategies, such as consumer groups. You can use streams to record and simultaneously syndicate events in real time. Examples of Redis stream use cases include:

Event sourcing (e.g., tracking user actions and clicks)

Sensor monitoring (e.g., readings from devices in the field)

Notifications (e.g., storing a record of each user's notifications in a separate stream)

Redis generates a unique ID for each stream entry. You can use these IDs to retrieve their associated entries later or to read and process all subsequent entries in the stream. Note that because these IDs are related to time, the ones shown here may vary and will be different from the IDs you see in your own Redis instance.

Redis streams support several trimming strategies (to prevent streams from growing unbounded) and more than one consumption strategy (see XREAD, XREADGROUP, and XRANGE).

The following table compares the performance of stream and Publish/Subscribe:

Item

Stream

Pub/Sub

Persistence

Support

Not supported

Consumer groups

Support

Not supported

Consumption confirmation

Support

Not supported

Performance

Excellent performance regardless of the number of clients

A noticeable drop in performance for multiple clients

Data isolation

Independent data between DBs

Dependent data between DBs

|Module APIs

Support for new Redis module APIs: Timer, cluster, and dictionary APIs

LUA improvements

LUA scripts can be copied to the standby database.

LUA scripts allow timeout.

Dynamic hz

The hz of the previous Redis versions has a fixed value. The new version supports hz dynamic changes to balance CPU and responsiveness.

New ZPOP Command

The following commands are added for SORTED SET:

Command

Feature

Link

ZPOPMIN

Removes and returns the value with the lowest score in the Sorted Set. When left unspecified, the default value is 1.

https://redis.io/commands/zpopmin/

ZPOPMAX

Removes and returns the value with the highest score in the Sorted Set. When left unspecified, the default value is 1.

https://redis.io/commands/zpopmax/

BZPOPMIN

BZPOPMIN is the blocking variant of the sorted set ZPOPMIN primitive.

https://redis.io/commands/bzpopmin/

BZPOPMAX

BZPOPMAX is the blocking variant of the sorted set ZPOPMAX primitive.

https://redis.io/commands/bzpopmax/


v_dXnccXp2IL