php连接redis类
- 代码:
]> */ 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"
文章题目:php连接redis类
分享链接:http://myzitong.com/article/ieidjg.html