The problem/use-case that the feature addresses
When I want to use the wait command in my code, I want the numreplica to be equal to the number of all replicas,but redis does not provide a command that can return the number of replicas.If my timeout is 0 and numreplicas exceed the actual number, it will be blocked forever.
Currently, we can only use the info command to see connected_ Slaves: (number), but the code has no eyes. I can only let the code do a series of string operations to get it, which makes the code more complex and increases the code execution time.(Or is there another way to get it? Please let me know if there is a better way)
I think redis needs to provide a command to return the number of replicas. This is to provide a reference for the numreplicas parameter of the wait command and other purposes.
Description of the feature
A command that returns the number of slave nodes connected to the current master node,maybe we can call it numofreplicas.
Comment From: oranagra
seems related to https://github.com/redis/redis/pull/8684 The problem is that it could be that some replicas got disconnected, and then you won't wait for them. Indicating that the number of replicas to wait for depends on the configuration, and not the current state.
Comment From: ncghost1
@oranagra
Adding this new command for the numreplica of the wait command is what I personally want at present, of course support all and other representatives numreplicas is better to use wait command.
Thank you for telling me the problem about using wait.
Put the wait command aside. Let's discuss the new command. Is it feasible to add this new command for future needs? For example, for some possible commands in the future that require the numreplicas parameter, it is indeed possible to add the optional parameter all to them, but sometimes we may not need all, we may only need half, one third, and so on.So if we can get the number of replicas, we can use them flexibly according to our own needs.
Comment From: oranagra
@ncghost1 it is unlikely that we'll add a dedicated command just to get that specific piece of info.
we have the INFO command for such things.
same as the ROLE command that we have now, which i'm guessing is obsolete.
I don't understand what you mean by but the code has no eyes.
maybe it would be easier for you see see the length of the array returned by ROLE.
Comment From: ncghost1
but the code has no eyes
This means that we can use our eyes to get the information in the INFO command, but in the code implementation, it need to match and split the string to get specific information.
Thank you for your suggestion. I will try to use ROLE.
Then I will close the issue.