Ioredis would like to send commands to multiple nodes in the cluster (such as flushall and keys).
After reviewing the following documentation, I was going to use the node list that I got from Cluster#nodes, but when I called Cluster#nodes, it returned an empty array and I couldn't continue.
https://github.com/luin/ioredis/blob/master/README.md
Running commands to multiple nodes item
We are testing with the following source code to verify the node list.
var Redis=require('ioredis');
varcluster=newRedis.Cluster([{{
host: '127.0.0.1',
port —7000
}, {
host: '127.0.0.1',
port —7001
}, {
host: '127.0.0.1',
port —7002
}]);
console.log(cluster.nodes());
When I tried outputting the cluster, the nodes did not contain any values as shown below.
Cluster{
domain —null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
slots: [ ],
retryAttempts: 0,
delayQueue:DelayQueue {queues:{},timeouts:{},
offlineQueue:
US>Denque{
_head —0,
_tail —0,
_capacityMask—3,
_list: <4 empty items>},
isRefreshing: false,
connectionEpoch: 1,
options:
{ showFriendlyErrorStack: false,
clusterRetryStratey: Function: clusterRetryStratey,
enableOfflineQueue: true,
enableReadyCheck: true,
scaleReads: 'master',
maxRedirections—16,
retryDelayOnFailover: 100,
retryDelayOnClusterDown: 100,
retryDelayOnTryAgain: 100,
slotsRefreshTimeout: 1000,
slotsRefreshInterval: 5000,
dnsLookup: Function:lookup},
scriptsSet: {},
startupNodes:
[{host:'127.0.0.1', port:7000},
{ host: '127.0.0.1', port:7001},
{ host: '127.0.0.1', port:7002} ,
connectionPool:
ConnectionPool {
domain —null,
_events:
{ '-node': Array,
'+node': Array,
drain —Function,
nodeError: Function},
_eventsCount—4,
_maxListeners: undefined,
redisOptions: undefined,
nodes: {all:{}, master:{}, slave:{},
specifiedOptions: {},
subscriber:
ClusterSubscriber {
connectionPool:
ConnectionPool {
domain —null,
_ events —Object,
_eventsCount—4,
_maxListeners: undefined,
redisOptions: undefined,
nodes —Object,
specifiedOptions: {},
emitter: Circular,
started: false,
subscriber:null},
status: 'connecting'}
Please let me know if there is anything wrong or missing.
redis
You can now retrieve node information with the following correspondence:
var Redis=require('ioredis');
varcluster=newRedis.Cluster([{{
host: '127.0.0.1',
port —7000
}, {
host: '127.0.0.1',
port —7001
}, {
host: '127.0.0.1',
port —7002
}]);
// console.log (cluster);
cluster.on('connect',()=>{
console.log(cluster);
});
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.