php有redis的扩展,目前来说,还不支持redis cluster,推荐一下predis,功能比较全,从单个,到主从,到cluster都是支持的。效率怎么样,要靠自己去测试一下。
1,下载predis
https://github.com/nrk/predis
2,predis 事例
- <?php
- require 'autoload.php';
- $servers = array(
- 'tcp://192.168.10.219:6379',
- 'tcp://192.168.10.219:6380',
- 'tcp://192.168.10.219:6381',
- 'tcp://192.168.10.220:6382',
- 'tcp://192.168.10.220:6383',
- 'tcp://192.168.10.220:6384',
- );
- $options = array('cluster' => 'redis');
- $client = new PredisClient($servers, $options);
- $client->set("test", "tank");
- $result = $client->get("test");
- var_dump($result);