Redis Stream command

XACK

XACK key group ID [ID ...]

#Example

redis> XACK mystream mygroup 1526569495631-0
ERR Unknown or disabled command 'XACK'

Marks a pending message as correctly processed, effectively removing it from the pending entries list of the consumer group. Return value of the command is the number of messages successfully acknowledged, that is, the IDs we were actually able to resolve in the PEL.

XLEN

XLEN key

#Example

redis> XADD mystream \* item 1
"1609040580250-0"
redis> XADD mystream \* item 2
"1609040580250-1"
redis> XADD mystream \* item 3
"1609040580251-0"
redis> XLEN mystream
(integer) 3

Return the number of entries in a stream

XREVRANGE

XREVRANGE key end start [COUNT count]

#Example

redis> XADD writers \* name Virginia surname Woolf
"1609040579130-0"
redis> XADD writers \* name Jane surname Austen
"1609040579130-1"
redis> XADD writers \* name Toni surname Morrison
"1609040579130-2"
redis> XADD writers \* name Agatha surname Christie
"1609040579131-0"
redis> XADD writers \* name Ngozi surname Adichie
"1609040579131-1"
redis> XLEN writers
(integer) 5
redis> XREVRANGE writers + - COUNT 1
1) 1) "1609040579131-1"
   2) 1) "name"
      2) "Ngozi"
      3) "surname"
      4) "Adichie"

Return a range of elements in a stream, with IDs matching the specified IDs interval, in reverse order (from greater to smaller IDs) compared to XRANGE

XRANGE

XRANGE key start end [COUNT count]

#Example

redis> XADD writers \* name Virginia surname Woolf
"1609040578002-0"
redis> XADD writers \* name Jane surname Austen
"1609040578002-1"
redis> XADD writers \* name Toni surname Morrison
"1609040578003-0"
redis> XADD writers \* name Agatha surname Christie
"1609040578003-1"
redis> XADD writers \* name Ngozi surname Adichie
"1609040578003-2"
redis> XLEN writers
(integer) 5
redis> XRANGE writers - + COUNT 2
1) 1) "1609040578002-0"
   2) 1) "name"
      2) "Virginia"
      3) "surname"
      4) "Woolf"
2) 1) "1609040578002-1"
   2) 1) "name"
      2) "Jane"
      3) "surname"
      4) "Austen"

Return a range of elements in a stream, with IDs matching the specified IDs interval

XTRIM

XTRIM key MAXLEN [=|~] length

#Example

redis> XADD mystream \* field1 A field2 B field3 C field4 D
"1609040575750-0"
redis> XTRIM mystream MAXLEN 2
(integer) 0
redis> XRANGE mystream - +
1) 1) "1609040575750-0"
   2) 1) "field1"
      2) "A"
      3) "field2"
      4) "B"
      5) "field3"
      6) "C"
      7) "field4"
      8) "D"

Trims the stream to (approximately if '~' is passed) a certain size

XADD

XADD key [MAXLEN [=|~] length] [NOMKSTREAM] *|ID field value [field value ...]

#Example

redis> XADD mystream \* name Sara surname OConnor
"1609040574632-0"
redis> XADD mystream \* field1 value1 field2 value2 field3 value3
"1609040574632-1"
redis> XLEN mystream
(integer) 2
redis> XRANGE mystream - +
1) 1) "1609040574632-0"
   2) 1) "name"
      2) "Sara"
      3) "surname"
      4) "OConnor"
2) 1) "1609040574632-1"
   2) 1) "field1"
      2) "value1"
      3) "field2"
      4) "value2"
      5) "field3"
      6) "value3"

Appends a new entry to a stream

Comments