Skip to content

Scan Iterator on RedisCluster #2657

Open
@leibale

Description

@leibale

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions