A redis client wrapper to support cluster connections.
This library can be used as a drop-in replacement for the regular node_redis client.
npm install redis-party
var nodes ="host": "node1.domain.com" "port": 10000"host": "node1.domain.com" "port": 10001"host": "node2.domain.com" "port": 10000"host": "node2.domain.com" "port": 10001;var redis = ;var cluster = nodes "max_attempts": 5;cluster;
Alternative node_redis compatible interface:
var client = redis;client;
Just like node_redis, each redis command is exposed as a function on the client object.
All commands except
multi are passed along to the correct node_redis client depending on the key hash.
The client will emit the ready event once the client is connected to the cluster and has populated the slot-node mapping table.
This client will emit the error event if there is an error with the cluster library.
Error events emitted from the node_redis library.
message (channel, message)
Client will emit
message for every message received that matches an active subscription.
This event is emitted when a cluster config change has been detected. The cluster slot-node mapping table will be re-initialized,
ready event will be emitted again once that is done.
cluster.createClient(port, host, options, [callback])
Create a new cluster instance. It will connect to the specified redis node and discover the rest of the nodes from there.
port- defaults to
host- defaults to
options- same as node_redis client options
cluster.Cluster(nodes, redisOptions, callback)
Create a new cluster instance. It will connect to the first available redis node and discover the rest of the nodes from there.
nodes- an array of objects with
redisOptions- node_redis client options. See node_redis documentation.
Cleanly end connections to all cluster nodes by sending the
QUIT command after handling all replies.
Returns the slot which will be used for a key.
Get the node_redis instance for a specific slot.