Introduction
XRANGE and XREVRANGE help you read messages from a Redis stream in order, either from oldest to newest or newest to oldest.
XRANGE key start end [COUNT count] XREVRANGE key end start [COUNT count]
XRANGE mystream - +
XRANGE mystream 1609459200000-0 1609459300000-0 COUNT 5
XREVRANGE mystream + -
XREVRANGE mystream 1609459300000-0 1609459200000-0 COUNT 3
XADD mystream * sensor_id 1 temperature 22.5 XADD mystream * sensor_id 2 temperature 23.0 XRANGE mystream - + XREVRANGE mystream + - COUNT 1
XRANGE do when used on a stream?XREVRANGE?mystream with entries:1609459200000-0: {"name":"Alice"}1609459260000-0: {"name":"Bob"}1609459320000-0: {"name":"Carol"}XRANGE mystream 1609459200000-0 1609459260000-0?XREVRANGE mystream - + COUNT 3 on a stream with more than 3 entries but get an empty list. What is the likely cause?mystream but only those with IDs greater than 1609459200000-0. Which command achieves this correctly?Pass the test and this pattern moves unknown