ScriptedCommand.php 890 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis\Commands;
  11. abstract class ScriptedCommand extends ServerEval
  12. {
  13. public abstract function getScript();
  14. protected function keysCount()
  15. {
  16. // The default behaviour for the base class is to use all the arguments
  17. // passed to a scripted command to populate the KEYS table in Lua.
  18. return count($this->getArguments());
  19. }
  20. protected function filterArguments(Array $arguments)
  21. {
  22. return array_merge(array($this->getScript(), $this->keysCount()), $arguments);
  23. }
  24. protected function getKeys()
  25. {
  26. return array_slice($this->getArguments(), 2, $this->keysCount());
  27. }
  28. }