大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

php连接redis类

  1. 代码:
    ]>
    */
    class phpredis extends Redis{
    public function connect($config){
        $host = $config['host'];
        $port = $config['port'];
        parent::connect($host,$port);
        $pass = @$config['pass']?:false;
        if($pass !== false){
            parent::auth($pass);
        }
        return $this;
    }
    }
  2. 测试:
    $config = array(
        'host'=>'192.168.8.81',
        'port'=>'6379',
        'pass'=>'123456'
    );
    $redis = new phpredis();
    $redis->connect($config);
    $redis->set('name','dollarphp');
    $ret = $redis->get('name');
    var_dump($ret);
  3. 输出:
    string(9) "dollarphp"

网页标题:php连接redis类
分享网址:http://dzwzjz.com/article/ieidjg.html
在线咨询
服务热线
服务热线:028-86922220
TOP