XRANGE

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

Query entries

Usage: XRANGE key start end.

Example

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

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

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

You may omit sequenceNumber. The start ID is filled with 0 and the end ID with 18,446,744,073,709,551,615, the maximum unsigned 8-byte integer.

  • XRANGE sensor-1234 1538319053569-0 1538319053569-18446744073709551615

When there are several fields, they are returned in insertion order.

Exclusive range

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

COUNT option

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

Example

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

Iterate

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

Example

Command>XRANGE sensor-1234 1538319053569-11 + COUNT 1
Result>1538319053570-0
Command>XRANGE sensor-1234 1538319053570-1 + COUNT 1
Result>1538319053573-0

Syntax

XRANGE key start end [COUNT count] |

  • Available since version 5.0.0.
  • Exclusive '(' for start and end 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.
SQL Select On Redis Enterprise 7.3.0 or later, try SELECT.

<< XLEN XRANGE XREVRANGE >>

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