XREAD

Since 1.1.0Streams

Syntax

XREAD [COUNT count] [MAXCOUNT maxcount] [MAXSIZE maxsize] [BLOCK ms] STREAMS key [key ...] id [id ...]
  • Flags: blocking, movablekeys, readonly
  • ACL categories: @blocking, @read, @slow, @stream
  • Arity: -4

Reads entries with IDs greater than the ones given, from one or more streams. Give one ID per stream after the keys: 0 for everything, $ for entries added after this call, + for the last entry.

Options

OptionEffect
COUNT countAt most count entries per stream.
MAXCOUNT maxcountAt most this many entries in the whole reply (Redis 8.10).
MAXSIZE maxsizeStop once the reply holds this many bytes of entries (Redis 8.10).
BLOCK millisecondsWait this long for new entries if there are none; 0 waits for ever.

Reply

  • An array of [key, entries] for each stream that had entries.
  • nil if none had, or BLOCK timed out.

Examples

> XADD s 1-0 t a
"1-0"
> XADD s 2-0 t b
"2-0"
> XREAD COUNT 1 STREAMS s 0
1) 1) "s"
   2) 1) 1) "1-0"
         2) 1) "t"
            2) "a"
> XREAD STREAMS s +
1) 1) "s"
   2) 1) 1) "2-0"
         2) 1) "t"
            2) "b"
> XREAD BLOCK 100 STREAMS s $
(nil)