Skip to content

Add novalues option to command HSCAN.#12765

Merged
oranagra merged 4 commits intoredis:unstablefrom
CharlesChen888:hscan-novalue-option
Jan 30, 2024
Merged

Add novalues option to command HSCAN.#12765
oranagra merged 4 commits intoredis:unstablefrom
CharlesChen888:hscan-novalue-option

Conversation

@CharlesChen888
Copy link
Copy Markdown
Contributor

@CharlesChen888 CharlesChen888 commented Nov 15, 2023

Add a way to HSCAN a hash key and get only the field names. To resolve #12749
Command syntax is now:

HSCAN key cursor [MATCH pattern] [COUNT count] [NOVALUES]

when NOVALUES is on, the command will only return keys in the hash.

@soloestoy soloestoy added the release-notes indication that this issue needs to be mentioned in the release notes label Nov 16, 2023
Copy link
Copy Markdown
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

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

Nice!

Maybe we need to modify the reply schema in hscan.json? At least the description which says "list of key/value pairs from the hash where each even element is the key, and each odd element is the value".

CharlesChen888 and others added 2 commits November 17, 2023 09:52
Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Copy link
Copy Markdown
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

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

Good, I have no more comments.

Some of the my comments apply to the ZSCAN NOSCORES PR too, for example the reply schema and the error message.

@soloestoy
Copy link
Copy Markdown
Contributor

@oranagra @itamarhaber please approve, this is not a major decision, but I'd like to have your agreement on the command's format.

@madolson
Copy link
Copy Markdown
Contributor

It was discussed in the other thread, but why did we decide to ignore the consideration about changing the return structure of this command? I think that should be a non-starter for this command, and would prefer extending HKEYS or HKSCAN over this.

@oranagra
Copy link
Copy Markdown
Member

approved in a core-team meeting

@oranagra
Copy link
Copy Markdown
Member

@CharlesChen888 is this ready to be merged? (it seems so to me)

@CharlesChen888
Copy link
Copy Markdown
Contributor Author

@oranagra I think this is ready.

redis/redis-doc#2612 The corresponding PR to doc is here, I will delete the ZSCAN part.

@oranagra oranagra merged commit f469dd8 into redis:unstable Jan 30, 2024
roggervalf pushed a commit to roggervalf/redis that referenced this pull request Feb 11, 2024
Add a way to HSCAN a hash key, and get only the filed names.
Command syntax is now:
```
HSCAN key cursor [MATCH pattern] [COUNT count] [NOVALUES]
```
when `NOVALUES` is on, the command will only return keys in the hash.

---------

Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
soloestoy pushed a commit to redis/redis-doc that referenced this pull request Mar 1, 2024
Doc of redis/redis#12765.

---------

Co-authored-by: Oran Agra <oran@redislabs.com>
soloestoy pushed a commit to valkey-io/valkey that referenced this pull request May 7, 2024
Command syntax is now:
```
ZSCAN key cursor [MATCH pattern] [COUNT count] [NOSCORES]
```
Return format:
```
127.0.0.1:6379> zadd z 1 a 2 b 3 c
(integer) 3
127.0.0.1:6379> zscan z 0
1) "0"
2) 1) "a"
   2) "1"
   3) "b"
   4) "2"
   5) "c"
   6) "3"
127.0.0.1:6379> zscan z 0 noscores
1) "0"
2) 1) "a"
   2) "b"
   3) "c"
```
when NOSCORES is on, the command will only return members in the zset,
without scores.

For client side parsing the command return, I believe it is fine as long
as the command is backwards compatible. The return structure are still
lists, what has changed is the content. And clients can tell the
difference by the subcommand they use.

Since `novalues` option of `HSCAN` is already accepted
(redis/redis#12765), I think similar thing can be done to `ZSCAN`.

---------

Signed-off-by: Chen Tianjie <TJ_Chen@outlook.com>
arthurkiller pushed a commit to arthurkiller/valkey that referenced this pull request May 7, 2024
Command syntax is now:
```
ZSCAN key cursor [MATCH pattern] [COUNT count] [NOSCORES]
```
Return format:
```
127.0.0.1:6379> zadd z 1 a 2 b 3 c
(integer) 3
127.0.0.1:6379> zscan z 0
1) "0"
2) 1) "a"
   2) "1"
   3) "b"
   4) "2"
   5) "c"
   6) "3"
127.0.0.1:6379> zscan z 0 noscores
1) "0"
2) 1) "a"
   2) "b"
   3) "c"
```
when NOSCORES is on, the command will only return members in the zset,
without scores.

For client side parsing the command return, I believe it is fine as long
as the command is backwards compatible. The return structure are still
lists, what has changed is the content. And clients can tell the
difference by the subcommand they use.

Since `novalues` option of `HSCAN` is already accepted
(redis/redis#12765), I think similar thing can be done to `ZSCAN`.

---------

Signed-off-by: Chen Tianjie <TJ_Chen@outlook.com>
funny-dog pushed a commit to funny-dog/redis that referenced this pull request Sep 17, 2025
Add a way to HSCAN a hash key, and get only the filed names.
Command syntax is now:
```
HSCAN key cursor [MATCH pattern] [COUNT count] [NOVALUES]
```
when `NOVALUES` is on, the command will only return keys in the hash.

---------

Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[NEW]Scan for hash fields only

5 participants