Node.js 正在连接到 redis 集群
Node.js Connecting to redis cluster
有大量连接到 redis "server" 的示例和资源,但没有连接到 redis "cluster"。
我目前拥有的是:
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 ]
}
});
但这是针对单个 redis 服务器而不是集群。我将如何连接到我的集群?
看看这个图书馆 ioredis
我认为这会帮助您解决问题。
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
中的自述文件选项卡
有大量连接到 redis "server" 的示例和资源,但没有连接到 redis "cluster"。
我目前拥有的是:
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 ]
}
});
但这是针对单个 redis 服务器而不是集群。我将如何连接到我的集群?
看看这个图书馆 ioredis
我认为这会帮助您解决问题。
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
中的自述文件选项卡