require __DIR__.'/../autoload.php';
//redis实例
$servers = array(
'10.10.10.171:7000',
'10.10.10.171:7001',
'10.10.10.171:7002',
'10.10.10.171:7003',
'10.10.10.171:7004',
'10.10.10.171:7005',
);
$options = ['cluster' =>'redis','parameters' => [
'password' => '123456'
]];
$client = new Predis\Client($servers,$options);
$client->set('foo1','11');
$client->set('foo2','22');
$client->set('foo3','33');
// 此方法用于找出所有key名以foo开头的key
$allkeys = [];
$cmdKeys = $client->createCommand('keys', ['foo*']);
foreach ($client->getConnection() as $nodeConnection) {
$nodeKeys = $nodeConnection->executeCommand($cmdKeys);
$allkeys = array_merge($allkeys, $nodeKeys);
}
print_r($allkeys);