标签:phpredis连接函数
<?php
/*
@desc:redis连接函数
@author:lee <complet@163.com>
*/
function redis_connect($config){
$host = $config[‘host‘];
$port = $config[‘port‘];
$pass = @$config[‘pass‘]?:false;
$redis = new Redis();
$redis->connect($host,$port);
if($pass !== false){
$redis->auth($pass);
}
return $redis;
}
$config = array(
‘host‘=>‘192.168.8.81‘,
‘port‘=>‘8143‘,
‘pass‘=>‘123456‘
);
$redis = redis_connect($config);
$ret = $redis->get(‘name‘);
var_dump($ret);
string(9) "dollarphp"
标签:phpredis连接函数
原文地址:http://blog.51cto.com/12173069/2122279