Grokzen / redis-py-cluster

Python cluster client for the official redis cluster. Redis 3.0+.
https://redis-py-cluster.readthedocs.io/
MIT License
1.1k stars 316 forks source link

Support for PSYNC #505

Closed NirmalP29 closed 2 years ago

NirmalP29 commented 2 years ago

I want to implement redis replication protocol and received and process all the data from master. For that I am trying to use PSYNC command but it is not working as expected.

print(redisConnection.execute_command("psync", "feb44376baeb44e67ce83826961cbe155934eacc", "150130990"))
Output - 
b'CONTINUE'

redis-py-cluster 2.1.3 How can I control which node should receive this command? And how can I read the data received?

Grokzen commented 2 years ago

@NirmalP29 The simplest answer is that you don't do it through this class as the more management style of commands is absolute best suited to be done via the normal Redis class instance directly towards the node you want to interact with.

But you can manually dig up the Redis object instance for the master node if you try to look for it manually in the connection pool object ClusterConnectionPool and the internal object nodes and you should be able to find the Redis instance for your master node that you want to send this to.

I highly recommend that you migrate over to a later version of redis-py that now supports clustering based on the work from this repo and attempt to solve it through what new code they have written to support node targeting solutions.