Skip to content

Xread last entry in stream (#7388)#13117

Merged
oranagra merged 7 commits intoredis:unstablefrom
ronen-kalish:xread-last-entry-in-stream-7388
Mar 13, 2024
Merged

Xread last entry in stream (#7388)#13117
oranagra merged 7 commits intoredis:unstablefrom
ronen-kalish:xread-last-entry-in-stream-7388

Conversation

@ronen-kalish
Copy link
Copy Markdown
Collaborator

@ronen-kalish ronen-kalish commented Mar 6, 2024

Allow using + as a special ID for last item in stream on XREAD command.

This would allow to iterate on a stream with XREAD starting with the last available message instead of the next one which $ is used for.
I.e. the caller can use BLOCK and + on the first call, and change to $ on the next call.

Closes #7388

when '+' is used as item ID in XREAD command, return the last item in
the stream (provided the stream is not empty). Reduce the stream last
ID by one and start searching from there.
@ronen-kalish ronen-kalish force-pushed the xread-last-entry-in-stream-7388 branch from de9f9cb to a48443b Compare March 6, 2024 16:02
@ronen-kalish ronen-kalish force-pushed the xread-last-entry-in-stream-7388 branch from a48443b to 8f3426a Compare March 6, 2024 16:05
@ronen-kalish ronen-kalish requested a review from oranagra March 6, 2024 16:20
@sundb sundb linked an issue Mar 7, 2024 that may be closed by this pull request
@sundb
Copy link
Copy Markdown
Collaborator

sundb commented Mar 7, 2024

i guess that your editor formats the file automatically.

@oranagra oranagra requested a review from guybe7 March 7, 2024 14:11
ronen-kalish and others added 3 commits March 7, 2024 16:41
when '+' is used as item ID in XREAD command, return the last item in
the stream (provided the stream is not empty). Reduce the stream last
ID by one and start searching from there.
Copy link
Copy Markdown
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. waiting for ack from @guybe7

@oranagra oranagra added state:major-decision Requires core team consensus approval-needed Waiting for core team approval to be merged labels Mar 11, 2024
@oranagra
Copy link
Copy Markdown
Member

@redis/core-team please approve

@oranagra
Copy link
Copy Markdown
Member

approved in a core-team meeting.
@ronen-kalish can you make a redis-doc PR?

sundb added a commit that referenced this pull request Aug 14, 2024
Fixed a missing from #13117.
When the number of streams is incorrect, the error message for `XREAD`
needs to include the '+' symbol.
funny-dog pushed a commit to funny-dog/redis that referenced this pull request Sep 17, 2025
Allow using `+` as a special ID for last item in stream on XREAD
command.

This would allow to iterate on a stream with XREAD starting with the
last available message instead of the next one which `$` is used for.
I.e. the caller can use `BLOCK` and `+` on the first call, and change to
`$` on the next call.

Closes redis#7388

---------

Co-authored-by: Felipe Machado <[email protected]>
funny-dog pushed a commit to funny-dog/redis that referenced this pull request Sep 17, 2025
Fixed a missing from redis#13117.
When the number of streams is incorrect, the error message for `XREAD`
needs to include the '+' symbol.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval-needed Waiting for core team approval to be merged release-notes indication that this issue needs to be mentioned in the release notes state:major-decision Requires core team consensus state:needs-doc-pr requires a PR to redis-doc repository

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Feature request: XREAD support for reading last message from stream

5 participants