diff --git a/examples/ServerSideScripting.php b/examples/ServerSideScripting.php new file mode 100644 index 00000000..df1599c5 --- /dev/null +++ b/examples/ServerSideScripting.php @@ -0,0 +1,32 @@ +getProfile()->defineCommand('increx', 'IncrementExistingKey'); + +$client->set('foo', 10); +var_dump($client->increx('foo')); // int(11) +var_dump($client->increx('bar')); // NULL diff --git a/lib/Predis/Commands/ScriptedCommand.php b/lib/Predis/Commands/ScriptedCommand.php new file mode 100644 index 00000000..8224a1cc --- /dev/null +++ b/lib/Predis/Commands/ScriptedCommand.php @@ -0,0 +1,21 @@ +getArguments()); + } + + protected function filterArguments(Array $arguments) { + return array_merge(array($this->getScript(), $this->keysCount()), $arguments); + } + + protected function getKeys() { + return array_slice($this->getArguments(), 2, $this->keysCount()); + } +} diff --git a/lib/Predis/Commands/ServerEval.php b/lib/Predis/Commands/ServerEval.php new file mode 100644 index 00000000..b214bf67 --- /dev/null +++ b/lib/Predis/Commands/ServerEval.php @@ -0,0 +1,13 @@ + '\Predis\Commands\ServerInfoV24x', 'client' => '\Predis\Commands\ServerClient', + 'eval' => '\Predis\Commands\ServerEval', )); } }