PHP Redis Client and Cluster
Set up the Redis Cluster
try {
$this->clientCluster = new Client($redisHostCluster, array('cluster' => 'redis'));
$logger->debug("Successfully set up Redis");
} catch (\Exception $e) {
$logger->error("Couldn't connected to Redis");
$logger->error($e->getMessage());
}
The settings are here in the .ini
redisHostCluster[] = 'tcp://cluster-jobs-0001-001.pnuura.0001.use1.cache.amazonaws.com?timeout=10&read_write_timeout=10'
redisHostCluster[] = 'tcp://cluster-jobs-0001-002.pnuura.0001.use1.cache.amazonaws.com?timeout=10&read_write_timeout=10'
redisHostCluster[] = 'tcp://cluster-jobs-0002-001.pnuura.0001.use1.cache.amazonaws.com?timeout=10&read_write_timeout=10'
redisHostCluster[] = 'tcp://cluster-jobs-0002-002.pnuura.0001.use1.cache.amazonaws.com?timeout=10&read_write_timeout=10'
redisHostCluster[] = 'tcp://cluster-jobs-0003-001.pnuura.0001.use1.cache.amazonaws.com?timeout=10&read_write_timeout=10'
redisHostCluster[] = 'tcp://cluster-jobs-0003-002.pnuura.0001.use1.cache.amazonaws.com?timeout=10&read_write_timeout=10'
In the ConfigUtil, it will automatically load the array.
$redisHostCluster = $config['redisHostCluster'];
References:
http://stackoverflow.com/questions/35599977/redisclusterexception-with-phpredis-when-connecting-to-redis-cluster-which-is-no
https://www.zybuluo.com/phper/note/248555
https://github.com/nrk/predis
https://github.com/nrk/predis/wiki
PHP Redis Client and Cluster
猜你喜欢
转载自sillycat.iteye.com/blog/2357353
今日推荐
周排行