XREVRANGE

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Query entries in reverse

Usage: XREVRANGE key end start.

Example

Command>XREVRANGE sensor-1234 + -
Result>1) 1) 1538319053569-1
    2) 1) "temperature"
        2) "98.8"
2) 1) 1538319053569-0
    2) 1) "temperature"
        2) "98.7"

+ - returns every entry in the stream.
You can specify IDs; those IDs are included.

  • XREVRANGE sensor-1234 1538319053569-99 1538319053569-10
  • XREVRANGE sensor-1234 + 1538319053569
  • XREVRANGE sensor-1234 1538319053569 -
  • XREVRANGE sensor-1234 1538319053569 1538319053569

You may omit sequenceNumber. The end ID is filled with 18,446,744,073,709,551,615 and the start ID with 0.

  • XREVRANGE sensor-1234 1538319053569-18446744073709551615 1538319053569-0

Exclusive range

By default the given IDs are included. Prefix an ID with '(' to exclude it.
XREVRANGE sensor-1234 (1538319059570 (1538319053569
Added in version 6.2.

COUNT option

COUNT limits how many entries are returned. Entries with an ID less than or equal to the end ID are returned.

Example

Command>XREVRANGE sensor-1234 + 1538319053569-10 COUNT 1
Result>1538319053569-10

Iterate

Subtract 1 from the last ID and run the command again to continue. This is similar to SCAN on other types.

Example

Command>XREVRANGE sensor-1234 + 1538319053569-9 COUNT 1
Result>1538319053569-0
Command>XREVRANGE sensor-1234 + 1538319053568 COUNT 1
Result>1538319053568-0

Syntax

XREVRANGE key end start [COUNT count]

  • Available since version 5.0.0.
  • Exclusive '(' for end and start IDs was added in version 6.2.
  • Time complexity is O(log(N)+M), where N is the number of stream entries and M is the number of entries returned.

<< XRANGE XREVRANGE XREAD >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.