From 42c1653745a9d478b5c801168140c2c42d14c1a0 Mon Sep 17 00:00:00 2001 From: Ronen Kalish Date: Wed, 13 Mar 2024 10:34:22 +0200 Subject: [PATCH 1/2] Add description for XREAD new '+' special ID for last stream entry (#7388) --- commands/xread.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/commands/xread.md b/commands/xread.md index 0a6741519f..de70b67c9c 100644 --- a/commands/xread.md +++ b/commands/xread.md @@ -183,6 +183,26 @@ Once we get some replies, the next call will be something like: And so forth. +## The special `+` ID + +It is sometimes desirable to read the last entry in a stream. For a single +stream this can be easily achieved using the `XREVRANGE` command, like so: + +``` +> XREVRANGE stream + - COUNT 1 +``` +But if there are many streams involved, this approach is quickly becoming +too slow, having to issue a command per stream. +Instead, starting from redis 7.6, the `+` sign can be used as a special ID, +requesting the last available entry in a stream. For example: + +``` +> XREAD STREAM streamA streamB streamC streamD + + + + +``` + +Note that when using this special ID for a stream, the **COUNT** option will +be ignored (for the specific stream) since only the last entry can be returned. + ## How multiple clients blocked on a single stream are served Blocking list operations on lists or sorted sets have a *pop* behavior. From 4ba326ae710ff13da631a5475c4ba553d39ab194 Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Wed, 13 Mar 2024 17:04:07 +0200 Subject: [PATCH 2/2] Update xread.md --- commands/xread.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/xread.md b/commands/xread.md index de70b67c9c..2630f16be3 100644 --- a/commands/xread.md +++ b/commands/xread.md @@ -193,7 +193,7 @@ stream this can be easily achieved using the `XREVRANGE` command, like so: ``` But if there are many streams involved, this approach is quickly becoming too slow, having to issue a command per stream. -Instead, starting from redis 7.6, the `+` sign can be used as a special ID, +Instead, starting from redis 8.0, the `+` sign can be used as a special ID, requesting the last available entry in a stream. For example: ``` @@ -219,4 +219,4 @@ data to the stream. Reading the [Redis Streams introduction](/topics/streams-intro) is highly suggested in order to understand more about the streams overall behavior -and semantics. \ No newline at end of file +and semantics.