Closed matyhtf closed 5 years ago
https://github.com/swoole/swoole-src/issues/1630
public function handleResult($method, $arguments, $result) {
if ($method == 'zrank' && $result === null) {
return false;
}
if ($method == 'get' && $result === null) {
return false;
}
if (empty($result)) {
return $result;
}
if ($method == 'hmget') {
$keys = array_values($arguments[1]);
$rs = array();
foreach ($result as $k => $v) {
$rs[$keys[$k]] = $v;
}
$result = $rs;
} else if (
$method == 'hgetall' ||
(in_array($method, array('zrange', 'zrevrange')) && $arguments[3] == true) ||
(in_array($method, array('zrangebyscore', 'zrevrangebyscore')) && isset($arguments[3]) && $arguments[3]['withscores'])
) {
$keys = array_chunk($result, 2);
$rs = array();
foreach ($keys as $v) {
$rs[$v[0]] = $v[1];
}
$result = $rs;
}
return $result;
}
现状
目前
Co\Redis::hGetAll
直接返回了列表,没有进行 Map 化。与phpredis
不一致表现不一致。需要在
redis_request
完成后,重新组合 PHP 数组。修改
考虑到已经有很多
Swoole
的PHP
框架做了适配,可以新增一个参数,来设置开启兼容模式
。启用后,将重组
hGetAll
返回值为Map
格式。返回格式为: