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
@@ -164,6 +164,7 @@ class KeyPrefixProcessor implements ProcessorInterface
'GEOHASH' => 'static::first',
'GEOPOS' => 'static::first',
'GEODIST' => 'static::first',
'GEORADIUS' => 'static::georadius',
);
}
@@ -417,4 +418,31 @@ class KeyPrefixProcessor implements ProcessorInterface
$command->setRawArguments($arguments);
}
}
/**
* Applies the specified prefix to the key of a GEORADIUS command.
*
* @param CommandInterface $command Command instance.
* @param string $prefix Prefix string.
*/
public static function georadius(CommandInterface $command, $prefix)
{
if ($arguments = $command->getArguments()) {
$arguments[0] = "$prefix{$arguments[0]}";
if (($count = count($arguments)) > 5) {
for ($i = 5; $i < $count; ++$i) {
switch (strtoupper($arguments[$i])) {
case 'STORE':
case 'STOREDIST':
$arguments[$i] = "$prefix{$arguments[++$i]}";
break;
}
}
}
$command->setRawArguments($arguments);
}
}
}