node-redis
node-redis copied to clipboard
Scan Iterator on `RedisCluster`
Motivation
When using RedisCluster, the only way to "scan" the whole cluster is to loop over cluster.masters and use scan on each node, something like:
const results = await Promise.all(
cluster.masters.map(async master => {
const client = await cluster.nodeClient(master);
// you can use client.scan or client.scanIterator here
})
);
a scanIterator function on RedisCluster which will do that and merge to iterators (and maybe add an option to run the scan with some kind of concurrency rather than one by one?)
ref #2656
Basic Code Example
// scan node by node
for await (const keys of cluster.scanIterator()) {
// ...
}
// scan all nodes concurrently
for await (const keys of cluster.scanIterators({ concurrency: Infinity }) {
// ...
}
any update on that one?
@Loki-Afro PR's are welcome.. ;)