I am using this
redisManager.redisClient.keys('*example*', function (err, keys) { })
But it only gives keys from only one of the redis cluster. How can I get keys from all cluster?
1 Answers
Answers 1
You can't get keys for all nodes using a single command. You have to get keys for all nodes and merge them. Reference - https://github.com/antirez/redis/issues/1962
You can do something like.
var redis = require('redis'); redisConfig = new Array( {"port": 1234, "host": "192.168.1.2"}, {"port": 5678, "host": "192.168.1.3"} ); keys = new Array(); allKeys = new Array(); for(i = 0; i < redisConfig.length; i++){ redisClient = redis.createClient(redisConfig[i].port, redisConfig[i].host); keys[i] = redisClient.keys('*example*', function (err, keys) { allkeys = [...new Set([...allKeys ,...keys[i]])]; }) }
0 comments:
Post a Comment