-
Notifications
You must be signed in to change notification settings - Fork 946
Adds HGETDEL Support to Valkey #2851
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
base: unstable
Are you sure you want to change the base?
Conversation
Signed-off-by: Roshan Khatri <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #2851 +/- ##
============================================
+ Coverage 72.26% 72.43% +0.17%
============================================
Files 128 128
Lines 70370 70401 +31
============================================
+ Hits 50851 50998 +147
+ Misses 19519 19403 -116
🚀 New features to boost your workflow:
|
|
@valkey-io/core-team I would like to add this pr to next meeting agenda to discuss more, Thanks |
|
I think it is one feature to align with Redis 8 |
|
If it's the same syntax as in Redis 8, I vote YES. |
It is not, but I can make it the same |
|
Ah... Redis insist on using this very ugly syntax for all new commands. It appears to be designed for machine generated command lines, not humans. I think your syntax @valkey-io/client-maintainers WDYT? |
|
Yeah, it is the same as HTTL https://valkey.io/commands/httl/ The one I implemented is similar to HMGET: I think we have similar syntax in valkey as well so it would be generally better to keep compatibility |
|
I like consistency with HMGET better than creating a weird syntax just to align with Redis. That said, IF the 3rd parameter is a number AND the number equals the number of remaining parameters, we could just silently ignore it. But, unfortunately, that becomes ambiguous in a case like this: HGETDEL key 3 4 5 6 - is "3" a field? or a count of fields? |
hpatro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the syntax, users migrating from Redis to Valkey will have problems if we don't choose to stick with it. We have decided to stick through with so many of features so far (Hash field expiration / Search / JSON). So, I think we should continue have symmetry with them atleast on the data path commands which were introduced there first.
Signed-off-by: Roshan Khatri <[email protected]>
Signed-off-by: Roshan Khatri <[email protected]>
|
Breaking API with Redis will mean that client maintainers might need to choose sides, and only fully support one DB, and offer partial support for the other, which will also lead to poor UX for the client users, since these details are easy to miss, and expectations won't match reality. |
|
Updated the top comment and this PR now maintain syntax compatibility. |
|
I have one question: In Redis 8.0, it introduces this command HGETDEL, the open source license was changed before Redis 8.0. I am not sure how many users migrating from Redis 8.0 to Valkey? Do we need still align with the Redis weird syntax? Honestly, I do not like the format: HGETDEL key FIELDS numfields field [field ...] |
ranshid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave a quick one (and will continue tomorrow)
Looks good overall. I would be happy if we can also include a test in hashexpire.tcl to test the command when there are expired fields.
src/t_hash.c
Outdated
| dbUpdateObjectWithVolatileItemsTracking(c->db, o); | ||
| } | ||
| signalModifiedKey(c, c->db, c->argv[1]); | ||
| notifyKeyspaceEvent(NOTIFY_HASH, "hgetdel", c->argv[1], c->db->id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we aligned on adding a new keyspace event? I was thinking that since we only trigger this when we delete, we could just trigger an hdel keyspace event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also agree with hdel. I was unsure about it so I kept hgetdel
| { | ||
| "HGETDEL": { | ||
| "summary": "Returns the values of one or more fields and deletes them from a hash.", | ||
| "complexity": "O(N) where N is the number of fields to be retrieved and deleted.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I agree this should be O(N), but we should then fix the inconsistency, since for other commands we marked them as O(1) following PR review (eg httl, hpttl, hsetex etc...) HOWEVER for HMGET we did use O(N), so lets decide on the correct form and align all command docs. @valkey-io/core-team FYI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it needs to be O(N) as we will be looping over the number of fields.
I also do not like the FIELDS (although it has advantages for adding future command arguments), but I agree with the state that we should be more aligned with the client ecosystem needs and I think it is overriding personal taste ATM. |
|
As a client maintainer, I suggest aligning with the weird syntax as long as the command name remains the same. |
Signed-off-by: Roshan Khatri <[email protected]>
|
I vote for use Redis syntax. (for save time and compatibility, Redis client for Valkey, Valkey client for Redis)
|
|
@valkey-io/core-team Let me summarize the decision points:
|
Now the syntax is same as redis https://redis.io/docs/latest/commands/hgetdel/ |
|
@valkey-io/core-team do you want to try and take a decision offline (on this PR) or should I schedule this to be a topic on Monday? |
I vote yes, we can have this new command API
According to above comments from some contributors, it looks like it is better to align with Redis command syntax
Yes, O(n) is fine
I agree with this part coding logic. |
|
+1 for Wen's comments. (Yes, align with Redis syntax, O(n), single hdel event.) |
O.K so we have 2 TSC approvers. @zuiderkwast should we still wait for the next meeting or start driving it here? (simply asking: should I remove the majority needed?) |
| } | ||
|
|
||
| void hgetdelCommand(client *c) { | ||
| int fields_index = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a small comment like this to explain why 4.
/* argv: [0]=HGETDEL, [1]=key, [2]=FIELDS, [3]=numfields, [4...]=fields */
Fixes this: #2850
Adds support for HGETDEL to Valkey and aligns with Redis 8.0 feature.
Maintains syntax compatibility
Retrieves all the values, and null if fields dont exists and deletes once retrieved.