PHP函数查看redis 版本号
$redis_ext_refc = new ReflectionExtension('redis');
var_dump($redis_ext_refc->getVersion());
参考:
public function addServer($host = '127.0.0.1', $port = 6379, $dbIndex = 0, $weight = 1) {
$redis = new Redis();
$rhost = $host . ':' . $port;
$connection_string = $rhost . '/' . $dbIndex;
$redis_ext_refc = new ReflectionExtension('redis');
if (version_compare($redis_ext_refc->getVersion(), '2.1.0') <= 0) {
$bret = $redis->pconnect($host, $port, 0);
} else {
$bret = $redis->pconnect($host, $port, 0, $connection_string);
}
if ($bret) {
// $redis->select($dbIndex); // redis-proxy and high redis not support this anymore
$this->_hash->addTarget($rhost);
$this->_pool[$rhost] = $redis;
return true;
}
unset($redis);
return false;
}
赞赏码
非学,无以致疑;非问,无以广识