mirror of
https://github.com/predis/predis.git
synced 2026-08-25 01:09:40 +00:00
Scripting abstraction can use negatives to calculate number of keys.
With a negative number Predis will count from the end of the arguments list to calculate the actual number of keys that will be interpreted as elements for `KEYS` by the underlying `EVAL` command.
This commit is contained in:
@@ -60,8 +60,13 @@ abstract class ScriptedCommand extends ServerEval
|
||||
*/
|
||||
protected function filterArguments(Array $arguments)
|
||||
{
|
||||
$header = array($this->getScript(), ($keys = $this->getKeysCount()) !== false ? $keys : count($arguments));
|
||||
if (false !== $numkeys = $this->getKeysCount()) {
|
||||
$numkeys = $numkeys >= 0 ? $numkeys : count($arguments) + $numkeys;
|
||||
}
|
||||
else {
|
||||
$numkeys = count($arguments);
|
||||
}
|
||||
|
||||
return array_merge($header, $arguments);
|
||||
return array_merge(array($this->getScript(), $numkeys), $arguments);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user