Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to use the '*-123' pattern to specify stream entry ID via XADD #1405

Merged
merged 2 commits into from
Apr 29, 2023

Conversation

torwig
Copy link
Contributor

@torwig torwig commented Apr 27, 2023

Currently, Redis Stream has 3 strategies to form the new entry's ID (provided with the XADD command):

  • autogenerated: the * pattern
  • fully specified by the client: the 12345-6789 pattern
  • only the sequence number is auto-generated, and the timestamp is specified by the client: the 12345-* pattern.

This PR introduces an additional pattern *-12345 when a client is able to specify a sequence number and a timestamp will be generated by the Kvrocks server.
The new pattern allows clients to use their internal IDs as part of an entry ID.
Kvrocks generates timestamps and order incoming entries by the receiving time.

… via XADD

It allows Kvrocks server to set current timestamp as the first part of the
entry ID and provided by the client sequence number as the second part of it.
@aleksraiden
Copy link
Contributor

Awesome feature, we are waiting for this, lot of thanks! For example, we can use this streamID for checking latency for each message (if consumer after processing, store an result with a same ID, but new autogenerated part of time).

@aleksraiden
Copy link
Contributor

And some of futures - this feature will be pretty use with XMOVE/XCOPY next command planned too... ;)

@git-hulk git-hulk added feature type new feature release notes labels Apr 28, 2023
Copy link
Member

@PragmaTwice PragmaTwice left a comment

Choose a reason for hiding this comment

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

LGTM in general.

src/types/redis_stream_base.cc Outdated Show resolved Hide resolved
@torwig torwig requested a review from PragmaTwice April 28, 2023 17:20
@PragmaTwice PragmaTwice changed the title Add the ability to use the '*-123' pattern to specify stream entry ID… Add the ability to use the '*-123' pattern to specify stream entry ID via XADD Apr 28, 2023
Copy link
Member

@PragmaTwice PragmaTwice left a comment

Choose a reason for hiding this comment

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

LGTM. Awesome feature!

@PragmaTwice
Copy link
Member

Merging...

@PragmaTwice PragmaTwice merged commit 8cd5291 into apache:unstable Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature type new feature release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants