php连接redis类
<?php/*** @desc:phpredis连接类* @author:lee <[<complet@163.com>]>*/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;}}
测试:
$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);
输出:
string(9) "dollarphp"
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。