Skip to content

Replace HGETALL and SMEMBERS with Scan alternatives for large keys#232

Merged
ArgusLi merged 8 commits intomainfrom
196-replace-large-keys-commands-with-scans
Mar 6, 2026
Merged

Replace HGETALL and SMEMBERS with Scan alternatives for large keys#232
ArgusLi merged 8 commits intomainfrom
196-replace-large-keys-commands-with-scans

Conversation

@ArgusLi
Copy link
Contributor

@ArgusLi ArgusLi commented Feb 27, 2026

Description

In response to #196, this pr replaces the performance inhibiting HGETALL and SMEMBERS with HSCAN and SSCAN respectively. This reduces the burden on the Valkey server and the Valkey Admin client.


const [collectionSize] = await Promise.all([
client.customCommand([commands.sizeCmd, keyInfo.name]),
(async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

leave a comment explaining what this promise.all does, how come we have value-promise and a side-effect promise — it's 50+ loc to read to understand without a comment

if (commands.sizeCmd) {
promises.push(client.customCommand([commands.sizeCmd, keyInfo.name]))
}
promises.push(client.customCommand(commands.elementsCmd))
Copy link
Collaborator

@arseny-kostenko arseny-kostenko Feb 27, 2026

Choose a reason for hiding this comment

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

I guess, you could initialize with it?

const promises = [client.customCommand(commands.elementsCmd)]
if (commands.sizeCmd) {
      promises.push(client.customCommand([commands.sizeCmd, keyInfo.name]))
}

ArgusLi and others added 7 commits March 6, 2026 12:03
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: nassery318 <nassery318@gmail.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: nassery318 <nassery318@gmail.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: nassery318 <nassery318@gmail.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: nassery318 <nassery318@gmail.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
@ArgusLi ArgusLi force-pushed the 196-replace-large-keys-commands-with-scans branch from 1774936 to 7a9859e Compare March 6, 2026 20:03
Signed-off-by: Argus Li <43020525+ArgusLi@users.noreply.github.com>
@ArgusLi ArgusLi merged commit c09c9c6 into main Mar 6, 2026
7 checks passed
@ArgusLi ArgusLi deleted the 196-replace-large-keys-commands-with-scans branch March 6, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants