sewenew / redis-plus-plus

Redis client written in C++
Apache License 2.0
1.6k stars 347 forks source link

[QUESTION] How Do I navigate between Cluster Nodes ? #511

Closed ShadowKai closed 1 year ago

ShadowKai commented 1 year ago

Describe the problem I want to be able to use scan feature for my cluster but it seems to be only getting the keys in whatever master node it's currently in so I tried making a workaround.

So I'm able to get the cluster info from using this: cluster.redis("any-hash-tag").command("CLUSTER", "SLOTS");

the problem I'm facing is how do i navigate between the nodes ? when I was using the binary redis-cli I able to switch between nodes using "connect ".

I want to be able to switch to another node based on the IP/PORT or nodeid so that I am able to treat it like a normal redis scan, something like this:

std::unordered_set output; cluster.redis("any-hash-tag").scan(0, pattern, count, std::inserter(output, output.begin());

sewenew commented 1 year ago

If I understand correctly, after getting all nodes with CLUSTER SLOTS command, you can create a Redis object for each node, and then do scan with these Redis objects.

I want to be able to switch to another node based on the IP/PORT or nodeid

Do you mean that you want to switch to another node with an already created Redis object? This is not supported.

Regards

ShadowKai commented 1 year ago

assuming my cluster configuration is like this 127.0.0.1:8000 (master) 127.0.0.1:8001 (master) 127.0.0.1:8002 (master) 127.0.0.1:8003 (slave) 127.0.0.1:8004 (slave) 127.0.0.1:8005 (slave)

I want the cluster point to port 8000 and perform scan then point it to 8001 and perform scan again etc..., instead of creating a new redis object for each node then do scan with the redis object.

sewenew commented 1 year ago

Sorry, but you cannot do that with redis-plus-plus. You have to create a Redis object for each node.

Regards

ShadowKai commented 1 year ago

ohh, alright thanks for your help, @sewenew.