Skip to content

Instantly share code, notes, and snippets.

@tillkruss
Last active April 9, 2021 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tillkruss/7f1b25a0045946cf33c8d4fec3e2b459 to your computer and use it in GitHub Desktop.
Save tillkruss/7f1b25a0045946cf33c8d4fec3e2b459 to your computer and use it in GitHub Desktop.
PhpRedis Cluster Test
<?php
var_dump('PhpRedis: '. phpversion('redis'));
$redis = new RedisCluster(
null,
[
'tls://127.0.0.1:7001',
'tls://127.0.0.1:7002',
],
1.0, // timeout
1.0, // read timeout
false, // persistent
'secret password',
['verify_peer' => false]
);
$redis->setOption(
RedisCluster::OPT_SLAVE_FAILOVER,
RedisCluster::FAILOVER_ERROR
);
for ($i = 0; $i < 50; $i++) {
$relay->set("cluster-test:{$i}", random_bytes(32));
}
var_dump('Test key: ' . $redis->get('cluster-test:42'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment