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
Support for KEYS* command with redis clustering #172
Comments
I can't accept your request because it covers a very specific requirement for a single application (which means it could not be generally useful for everyone in terms of actual implementation) and, what's more, built upon a command which usage is generally discouraged if not for debugging or migration purposes. You should implement this in your own application with something like $allkeys = [];
$client = new Predis\Client([ /* list of nodes */ ], $options);
$cmdKeys = $client->createCommand('keys', ['username:*']);
foreach ($client->getConnection() as $nodeConnection) {
$nodeKeys = $nodeConnection->executeCommand($cmdKeys);
$allkeys = array_merge($allkeys, $nodeKeys);
} You could do this in other ways, which means it's not generic enough to be added to Predis for general use. |
That is awesome @nrk ! Does Predis have a built in function for getting the cluster's node list? That would make this dynamic and prevent the upkeep of a static node list for a few admin commands that will be rarely used. |
Well, yes and no. At least currently. You can specify one or more nodes without passing the whole list and do the following: $client = new Predis\Client(['127.0.0.1:6379', '127.0.0.1:6380'], ['cluster' => 'redis']);
$client->getConnection()->askClusterNodes(); Predis will connect to one of the initial nodes specified when creating the client (so they must be reachable) and reconfigure itself automatically to use the full list of nodes as returned by the command I will see what can be done to improve things in this sense. |
That would be excellent! Thank you nrk for an excellent library and your dedication to maintaining it. It is because of you that PHP has the most mature Redis library available. |
Any updates on this? How do I iterate on all active cluster nodes if the connections are lazily initialized? |
bump for the Keys feature... |
another bump for this feature |
I have a very similar requirement, need to search for pattern with keys in cluster, how can i do this in java ? @nrk or anyone.. |
+1 |
have you guys tried using hgetall? On Wed, Jul 15, 2015 at 2:05 AM, Dmitri Perunov notifications@github.com
|
@JasonLantz how does it suppose to help to get list of keys? Anyway, @nrk solution in second comment worked for me. Maybe it was fixed, maybe I've misunderstood and this is a correct behaviour. |
+1 |
1 similar comment
👍 |
See my comments on #338 for a better and updated solution on how to iterate over the master nodes of redis-cluster to perform some commands on each node or iterate the keyspace as a whole in a decently efficient way. |
+1 |
It would be possible to run a KEYS command on all nodes of a cluster, then combine the results. This makes it possible to search for a pattern of keys.
In my app, I want to be able to delete everything for a specific user. My key path is always username:stuff.
It is nearly a deal breaker to not be able to run KEYS username:* and then delete everything for a specific user found in the reply. I would really appreciate this feature!
The text was updated successfully, but these errors were encountered: