Node.js 连接到 redis 集群

Moo*_*916 5 redis node.js redis-cluster

有大量用于连接到 Redis“服务器”但不连接到 Redis“集群”的示例和资源。

我目前拥有的是:

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 ]
 }
});
Run Code Online (Sandbox Code Playgroud)

但这是针对单个 Redis 服务器而不是集群。我将如何连接到我的集群?

小智 1

查看这个ioredis库

我认为这将帮助您解决您的问题。