Add new command: GEORADIUS (Redis 3.2.0).

This commit is contained in:
Daniele Alessandri
2016-05-24 17:09:06 +02:00
parent b2284d015f
commit 00000fde4e
14 changed files with 405 additions and 0 deletions
+33
View File
@@ -171,6 +171,7 @@ abstract class ClusterStrategy implements StrategyInterface
'GEOHASH' => $getKeyFromFirstArgument,
'GEOPOS' => $getKeyFromFirstArgument,
'GEODIST' => $getKeyFromFirstArgument,
'GEORADIUS' => array($this, 'getKeyFromGeoradiusCommands'),
);
}
@@ -300,6 +301,38 @@ abstract class ClusterStrategy implements StrategyInterface
}
}
/**
* Extracts the key from GEORADIUS command.
*
* @param CommandInterface $command Command instance.
*
* @return string|null
*/
protected function getKeyFromGeoradiusCommands(CommandInterface $command)
{
$arguments = $command->getArguments();
$argc = count($arguments);
if ($argc > 5) {
$keys = array($arguments[0]);
for ($i = 5; $i < $argc; $i++) {
$argument = strtoupper($arguments[$i]);
if ($argument === 'STORE' || $argument === 'STOREDIST') {
$keys[] = $arguments[++$i];
}
}
if ($this->checkSameSlotForKeys($keys)) {
return $arguments[0];
} else {
return null;
}
}
return $arguments[0];
}
/**
* Extracts the key from ZINTERSTORE and ZUNIONSTORE commands.
*