Skip to content

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

Open
ArgusLi wants to merge 1 commit intomainfrom
196-replace-large-keys-commands-with-scans
Open

Replace HGETALL and SMEMBERS with Scan alternatives for large keys#232
ArgusLi wants to merge 1 commit 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.

Signed-off-by: Argus Li <contactme@chunkeili.com>

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]))
}

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.

2 participants