Skip to content

Commit 42c1653

Browse files
committed
Add description for XREAD new '+' special ID for last stream entry (#7388)
1 parent 7679858 commit 42c1653

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

commands/xread.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,26 @@ Once we get some replies, the next call will be something like:
183183

184184
And so forth.
185185

186+
## The special `+` ID
187+
188+
It is sometimes desirable to read the last entry in a stream. For a single
189+
stream this can be easily achieved using the `XREVRANGE` command, like so:
190+
191+
```
192+
> XREVRANGE stream + - COUNT 1
193+
```
194+
But if there are many streams involved, this approach is quickly becoming
195+
too slow, having to issue a command per stream.
196+
Instead, starting from redis 7.6, the `+` sign can be used as a special ID,
197+
requesting the last available entry in a stream. For example:
198+
199+
```
200+
> XREAD STREAM streamA streamB streamC streamD + + + +
201+
```
202+
203+
Note that when using this special ID for a stream, the **COUNT** option will
204+
be ignored (for the specific stream) since only the last entry can be returned.
205+
186206
## How multiple clients blocked on a single stream are served
187207

188208
Blocking list operations on lists or sorted sets have a *pop* behavior.

0 commit comments

Comments
 (0)