7

There are tons of examples and resources for connecting to a redis "server" but not to a redis "cluster".

What I currently have is:

const redis = require("redis"); 
const client = redis.createClient({
 port : 6379, // replace with your port
 host : '10.0.0.100', // replace with your hostanme or IP address
 password : 'Notforyou', // replace with your password
 // optional, if using SSL
 // use `fs.readFile[Sync]` or another method to bring these values in
 tls : {
 key : stringValueOfKeyFile, 
 cert : stringValueOfCertFile,
 ca : [ stringValueOfCaCertFile ]
 }
});

But this is for a single redis server not a cluster. How would I go about connecting to my cluster?

asked May 8, 2020 at 9:15

2 Answers 2

3

The Readme tab in redis npm package has this link(Clustering Guide) explaining how to connect to redis cluster with node under heading 'Clustering'. It's very simple, create a cluster instead of creating client and configure the nodes url as given in this example

answered Jan 18, 2022 at 7:17
Sign up to request clarification or add additional context in comments.

Comments

0

Check out this library ioredis

I think that this will help you with your issue.

answered May 8, 2020 at 9:26

4 Comments

Thanks, I'll try it out and get back to you!
That is awesome!
I am glad that this helped you :)

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.