node-redis icon indicating copy to clipboard operation
node-redis copied to clipboard

Scan Iterator on `RedisCluster`

Open leibale opened this issue 1 year ago • 2 comments

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 }) {
  // ...
}

leibale avatar Nov 21 '23 06:11 leibale

any update on that one?

Loki-Afro avatar Jan 15 '24 10:01 Loki-Afro

@Loki-Afro PR's are welcome.. ;)

leibale avatar Jan 16 '24 18:01 leibale