1. 程式人生 > >redis cluster搭建使用

redis cluster搭建使用

見部落格http://blog.csdn.net/fengshizty/article/details/51368004

簡單php使用:

1.下載predis類庫

2.NAMESPACE註冊。

3 ci demo:

    public function __construct()
    {
        parent::__construct();
        $this->config->load('redis_cluster');
        $servers = $this->config->item("servers");
        $options = ['cluster' => 'redis'];
        require APPPATH.'libraries/predis/autoload.php';
        $this->rediser = new \Predis\Client($servers, $options);
    }

redis_cluster.php配置如下:

<?php
$config['servers'] = array(
    'tcp://13.41.35.22:7000',
    'tcp://13.41.35.23:7000',
    'tcp://13.41.35.22:7001',
    'tcp://13.41.35.23:7001',
    'tcp://13.41.35.22:7002',
    'tcp://13.41.35.23:7002',
    'tcp://13.41.35.22:7003',
    'tcp://13.41.35.23:7003',
    'tcp://13.41.35.22:7004',
    'tcp://13.41.35.23:7004',
    'tcp://13.41.35.22:7005',
    'tcp://13.41.35.23:7005',
    'tcp://13.41.35.22:7006',
    'tcp://13.41.35.23:7006',
    'tcp://13.41.35.22:7007',
    'tcp://13.41.35.23:7007',
    'tcp://13.41.35.22:7008',
    'tcp://13.41.35.23:7008',
    'tcp://13.41.35.22:7009',
    'tcp://13.41.35.23:7009',
);

redis cluster是不支援批量操作的,例如mget mset等。