/** * Applies the specified prefix to the keys of Z[INTERSECTION|UNION]STORE. * * @param CommandInterface $command Command instance. * @param string $prefix Prefix string. */ public static function zsetStore(CommandInterface $command, $prefix) { if ($arguments = $command->getArguments()) { $arguments[0] = "{$prefix}{$arguments[0]}"; $length = (int) $arguments[1] + 2; for ($i = 2; $i < $length; $i++) { $arguments[$i] = "{$prefix}{$arguments[$i]}"; } $command->setRawArguments($arguments); } }
/** * Applies the specified prefix to the key of a MIGRATE command. * * @param CommandInterface $command Command instance. * @param string $prefix Prefix string. */ public static function migrate(CommandInterface $command, $prefix) { if ($arguments = $command->getArguments()) { $arguments[2] = "{$prefix}{$arguments[2]}"; $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]}"; $startIndex = $command->getId() === 'GEORADIUS' ? 5 : 4; if (($count = count($arguments)) > $startIndex) { for ($i = $startIndex; $i < $count; ++$i) { switch (strtoupper($arguments[$i])) { case 'STORE': case 'STOREDIST': $arguments[$i] = "{$prefix}{$arguments[++$i]}"; break; } } } $command->setRawArguments($arguments); } }