Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scanStream in cluster mode? #175

Closed
bkw opened this issue Oct 14, 2015 · 8 comments
Closed

scanStream in cluster mode? #175

bkw opened this issue Oct 14, 2015 · 8 comments

Comments

@bkw
Copy link

bkw commented Oct 14, 2015

it seems that scanStream() is not available when using ioredis.Cluster(), although scan() is.
Any particular reason for this, or is this a requestable feature? ;-)

@luin
Copy link
Collaborator

luin commented Oct 14, 2015

Commands that doesn't have a key name as the arguments(e.g. scan, keys & info) will be sent to a random node of the cluster. So that it doesn't make sense to provide scanStream in the cluster mode since it will only scan a random node instead of the whole cluster.

@bkw
Copy link
Author

bkw commented Oct 14, 2015

Ah, thanks for clearing that up.

@bkw bkw closed this as completed Oct 14, 2015
@bkw
Copy link
Author

bkw commented Oct 14, 2015

Is that also the case for the other scan commands like hscan?
I mean, they do have a key as an argument. Couldn't that work? And please excuse my ignorance about cluster internals.

@bkw bkw reopened this Oct 14, 2015
@luin
Copy link
Collaborator

luin commented Oct 14, 2015

Yes, you're right. Other scan commands work with cluster. I'll consider whether to implement it.
Any pr is welcome :-)

@luin luin closed this as completed in 755b71e Nov 19, 2015
@luin
Copy link
Collaborator

luin commented Nov 19, 2015

Released in v1.11.0 🚀

@geogeim
Copy link

geogeim commented Sep 12, 2017

tested with ioredis 3.1.4 and scanStream function is missing from Redis.Cluster

@AndyGura
Copy link

+1 on this. There is still no scanStream function in Redis.Cluster. However you can use cluster.subscriber.scanStream to scan on currently connected slot.

@jseparator
Copy link

    let nodes = redis.nodes('master'),
        scanNode = (nodeIndex) => {
            let node = nodes[nodeIndex];
            node.scanStream({
                count: 10000
            }).on('data', rs => {
                rs.forEach(r => console.debug("key", r));
            }).on('end', () => {
                console.info("scan end, node %s:%d", node.options.host, node.options.port);
                if (++nodeIndex < nodes.length) {
                    scanNode(nodeIndex);
                } else {
                    console.info("scan finished");
                    redis.quit();
                }
            });
            console.info("scan start, node %s:%d", node.options.host, node.options.port);
        };
    scanNode(0);

Iterate over all Cluster Master Nodes, and then scan every single Node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants