-
Notifications
You must be signed in to change notification settings - Fork 954
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
Conversation
Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #2851 +/- ##
=========================================
Coverage 72.41% 72.41%
=========================================
Files 128 128
Lines 70439 70469 +30
=========================================
+ Hits 51006 51029 +23
- Misses 19433 19440 +7
🚀 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 <rvkhatri@amazon.com>
Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
|
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.
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 <rvkhatri@amazon.com>
|
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?) |
|
Also +1 for Wen's comments. (Yes, align with Redis syntax, O(n), single hdel event.) |
|
|
|
||
| /* If hash doesn't exist, continue as already replied with NULL */ | ||
| if (o == NULL) continue; | ||
| if (hashTypeDelete(o, c->argv[i]->ptr)) { |
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.
NOTE: I know that I drove you to implement it this way, but now I thought of a reason why the old way might have been "useful". What should we do in case the same fields is provided multiple times?
For example:
HMSET myhash f1 a f2 b f3 c
HGETDEL myhash fields 3 f1 f1 f1
in your previous implementation is would be:
"a", "a", "a"
which is slightly less efficient, but might fits better with common sense.
In the CURRENT implementation it would yield :
"a", nill, nill
BTW - Redis does as as the CURRENT implementation does (which means they return "a", nill, nill)
IMO we are doing the right thing just need to make sure we document it correctly
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 just place a test for it, so that we know we do not break this in the future?
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.
@valkey-io/core-team I think we are taking the right decision (although maybe common sense would say otherwise), just raising this as an FYI
#2875) When we added the Hash Field Expiration feature in Valkey 9.0, some of the new command docs included complexity description of O(1) even tough they except multiple arguments. (see discussion in #2851 (comment)) This PR does: 1. align all the commands to the same description 2. fix the complexity description of some commands (eg HSETEX and HGETEX) --------- Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
valkey-io#2875) When we added the Hash Field Expiration feature in Valkey 9.0, some of the new command docs included complexity description of O(1) even tough they except multiple arguments. (see discussion in valkey-io#2851 (comment)) This PR does: 1. align all the commands to the same description 2. fix the complexity description of some commands (eg HSETEX and HGETEX) --------- Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
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.
LGTM
valkey-io#2875) When we added the Hash Field Expiration feature in Valkey 9.0, some of the new command docs included complexity description of O(1) even tough they except multiple arguments. (see discussion in valkey-io#2851 (comment)) This PR does: 1. align all the commands to the same description 2. fix the complexity description of some commands (eg HSETEX and HGETEX) --------- Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Fixes this: valkey-io#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. ``` 127.0.0.1:6379> HGETDEL key FIELDS numfields field [ field ... ] ``` ``` 127.0.0.1:6379> HSET foo field1 bar1 field2 bar2 field3 bar3 (integer) 3 127.0.0.1:6379> HGETDEL foo FIELDS 1 field2 1) "bar2" 127.0.0.1:6379> HGETDEL foo FIELDS 1 field2 1) (nil) 127.0.0.1:6379> HGETALL foo 1) "field1" 2) "bar1" 3) "field3" 4) "bar3" 127.0.0.1:6379> HGETDEL foo FIELDS 2 field2 field3 1) (nil) 2) "bar3" 127.0.0.1:6379> HGETALL foo 1) "field1" 2) "bar1" 127.0.0.1:6379> HGETDEL foo FIELDS 3 field1 non-exist-field (error) ERR syntax error 127.0.0.1:6379> HGETDEL foo FIELDS 2 field1 non-exist-field 1) "bar1" 2) (nil) 127.0.0.1:6379> HGETALL foo (empty array) 127.0.0.1:6379> ``` --------- Signed-off-by: Roshan Khatri <rvkhatri@amazon.com> Signed-off-by: Ran Shidlansik <ranshid@amazon.com> Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
valkey-io#2875) When we added the Hash Field Expiration feature in Valkey 9.0, some of the new command docs included complexity description of O(1) even tough they except multiple arguments. (see discussion in valkey-io#2851 (comment)) This PR does: 1. align all the commands to the same description 2. fix the complexity description of some commands (eg HSETEX and HGETEX) --------- Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Fixes this: valkey-io#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. ``` 127.0.0.1:6379> HGETDEL key FIELDS numfields field [ field ... ] ``` ``` 127.0.0.1:6379> HSET foo field1 bar1 field2 bar2 field3 bar3 (integer) 3 127.0.0.1:6379> HGETDEL foo FIELDS 1 field2 1) "bar2" 127.0.0.1:6379> HGETDEL foo FIELDS 1 field2 1) (nil) 127.0.0.1:6379> HGETALL foo 1) "field1" 2) "bar1" 3) "field3" 4) "bar3" 127.0.0.1:6379> HGETDEL foo FIELDS 2 field2 field3 1) (nil) 2) "bar3" 127.0.0.1:6379> HGETALL foo 1) "field1" 2) "bar1" 127.0.0.1:6379> HGETDEL foo FIELDS 3 field1 non-exist-field (error) ERR syntax error 127.0.0.1:6379> HGETDEL foo FIELDS 2 field1 non-exist-field 1) "bar1" 2) (nil) 127.0.0.1:6379> HGETALL foo (empty array) 127.0.0.1:6379> ``` --------- Signed-off-by: Roshan Khatri <rvkhatri@amazon.com> Signed-off-by: Ran Shidlansik <ranshid@amazon.com> Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
valkey-io#2875) When we added the Hash Field Expiration feature in Valkey 9.0, some of the new command docs included complexity description of O(1) even tough they except multiple arguments. (see discussion in valkey-io#2851 (comment)) This PR does: 1. align all the commands to the same description 2. fix the complexity description of some commands (eg HSETEX and HGETEX) --------- Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Fixes this: valkey-io#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. ``` 127.0.0.1:6379> HGETDEL key FIELDS numfields field [ field ... ] ``` ``` 127.0.0.1:6379> HSET foo field1 bar1 field2 bar2 field3 bar3 (integer) 3 127.0.0.1:6379> HGETDEL foo FIELDS 1 field2 1) "bar2" 127.0.0.1:6379> HGETDEL foo FIELDS 1 field2 1) (nil) 127.0.0.1:6379> HGETALL foo 1) "field1" 2) "bar1" 3) "field3" 4) "bar3" 127.0.0.1:6379> HGETDEL foo FIELDS 2 field2 field3 1) (nil) 2) "bar3" 127.0.0.1:6379> HGETALL foo 1) "field1" 2) "bar1" 127.0.0.1:6379> HGETDEL foo FIELDS 3 field1 non-exist-field (error) ERR syntax error 127.0.0.1:6379> HGETDEL foo FIELDS 2 field1 non-exist-field 1) "bar1" 2) (nil) 127.0.0.1:6379> HGETALL foo (empty array) 127.0.0.1:6379> ``` --------- Signed-off-by: Roshan Khatri <rvkhatri@amazon.com> Signed-off-by: Ran Shidlansik <ranshid@amazon.com> Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
Fixes #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.