Commands | Description |
---|---|
XADD mystream * message 1 | Add to stream to insert {message: 1} |
XLEN mystream | Length of messages in mystream |
XRANGE mystream - + COUNT 2 | Return the first two elements |
XREAD COUNT 2 STREAMS mystream 0 | Read 2 elements in stream from the beginning |
XREAD BLOCK 0 STREAMS mystream $ | Wait indefinitely until a message |
XREAD BLOCK 1000 STREAMS mystream $ | Wait for 1 second for a message else timeout |
XGROUP CREATE mystream group1 $ | Create a group1 in consumer group in a stream |
XREADGROUP GROUP group1 cons1 COUNT 1 STREAMS mystream > | Consume new messages as cons1 in group1 and get all the new messages |
XREADGROUP GROUP group1 cons1 COUNT 1 STREAMS mystream id | Consume new messages as cons1 in group1 and get all the messages greater than ID |
XPENDING mystream group1 | Sends the messages which were consumed but didn’t receive acknowledgement |
XCLAIM mystream group1 cons2 1000 1604849974708-0 | Claim the pending ID as a different consumer in 1 second |
XDEL mystream 1526654999635-0 | Delete a particular ID |
XTRIM mystream MAXLEN ~ 10 | Keep approximately 10 recent elements in the stream (can keep more) - Will try to delete all the radix tree nodes within the limit |
XTRIM mystream MAXLEN 10 | Keep exactly 10 recent elements in the stream |
Last active
September 2, 2021 09:35
-
-
Save raj454raj/99e81a87ae124ebd2a3ce899a81201d8 to your computer and use it in GitHub Desktop.
Redis streams cheatsheet
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment