Skip to content

Conversation

@nfriedly
Copy link
Member

@nfriedly nfriedly commented Jul 1, 2024

I added @gamemaker1's example to the readme.

We'll wait for @Gandalf1783 to confirm it works before merging this in.

Fixes #207 (hopefully)

Please double-check this @gamemaker1 & @Gandalf1783

Fixes #207 (hopefully)
@thxrben
Copy link

thxrben commented Jul 1, 2024

As stated in #207 I will hopefully test this in the next few days.
Thanks for the quick response to my issue, didnt expect a PR to be already ready to be merged.

@nfriedly
Copy link
Member Author

nfriedly commented Jul 1, 2024

No rush; take care of yourself first and test this when you're ready :)

@mgiova
Copy link

mgiova commented Aug 4, 2025

The correct code is actually cluster.sendCommand(args[1], false, args)
Tested with node-redis 5.6.1

nfriedly added a commit to nfriedly/node-redis that referenced this pull request Aug 12, 2025
We noticed that `sendCommand()` takes different arguments for clusters vs clients, and I wanted to document the differences. I think I got it correct, but please review closely just to be sure.

It might also be worth adding a note to [the readme](https://github.com/redis/node-redis/blob/2f106324507eec905b8fe7691ba11179acdeeca7/README.md#L136-L144) also, since this is a somewhat unexpected difference, what do you think?

Relates to express-rate-limit/rate-limit-redis#207 & express-rate-limit/rate-limit-redis#208
use args[1] for firstKey instead of undefined so that commands are routed to the correct node instead of a random one.
@nfriedly nfriedly merged commit f2951ab into main Aug 13, 2025
16 checks passed
@nfriedly nfriedly deleted the doc-node-redis-cluster branch August 13, 2025 17:38
nfriedly added a commit that referenced this pull request Aug 13, 2025
nfriedly added a commit that referenced this pull request Nov 18, 2025
This adds a `sendCommandCluster` option as an alternative to `sendCommand`.

It can be set to a function that is passed an object with the key and isReadOnly value, in addition to the command. This provides everything that node-redis needs in cluster mode, and is expandable with new fields if necessary to support other libraries in cluster mode.

Additionally I tweaked the internals to always pass this information along - previously the key would be lost when loading the script, so it could inadvertenly get sent to the wrong redis server.

Fixes #222
Fixes #207
Fixes #208
nfriedly added a commit that referenced this pull request Nov 19, 2025
This adds a `sendCommandCluster` option as an alternative to `sendCommand`.

It can be set to a function that is passed an object with the key and isReadOnly value, in addition to the command. This provides everything that node-redis needs in cluster mode, and is expandable with new fields if necessary to support other libraries in cluster mode.

Additionally I tweaked the internals to always pass this information along - previously the key would be lost when loading the script, so it could inadvertenly get sent to the wrong redis server.

Fixes #222
Fixes #207
Fixes #208
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.

RedisStore: args.length: Cannot read properties of undefined (reading length).

4 participants