此BUG作者已更新:https://github.com/easy-swoole/redis/pull/23/files
问题原因 ,geoRadiusByMember 参数列表如下,使用Count的时候需要带上 Count X 条数,例如需要5条就是 Count 5,
GEORADIUSBYMEMBER key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
而框架提供的方法
geoRadiusByMember($key, $location, $radius, $unit, $withCoord, $withDist, $withHash, $count, $sort, $storeKey, $storeDistKey);
存在count参数,但是怎么设置也没有效果,设置数组还要报错,跟踪问题,定位
vendor/easyswoole/redis/src/Client.php文件方法,此处为考虑到count这种特殊情况,
public function sendCommand(array $commandList): bool
{
$argNum = count($commandList);
$str = "*{$argNum}\r\n";
foreach ($commandList as $value) {
$len = strlen($value);
$str = $str . '$' . "{$len}\r\n{$value}\r\n";
}
return $this->send($str);
}
修改如下,即可正常返回
public function sendCommand(array $commandList): bool
{
$argNum = 0;
foreach ($commandList as $data ){
if(is_array($data)){
$argNum = $argNum + (count($data) + 1);
}else{
$argNum ++;
}
}
$str = "*{$argNum}\r\n";
foreach ($commandList as $value) {
if(is_array($value)){
foreach ($value as $key => $values) {
$len = strlen($key);
$str = $str . '$' . "{$len}\r\n{$key}\r\n";
$len = strlen($values);
$str = $str . '$' . "{$len}\r\n{$values}\r\n";
}
}else{
$len = strlen($value);
$str = $str . '$' . "{$len}\r\n{$value}\r\n";
}
}
return $this->send($str);
}