ICommand.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. use Predis\Distribution\INodeKeyGenerator;
  12. /**
  13. * Defines an abstraction representing a Redis command.
  14. * @author Daniele Alessandri <suppakilla@gmail.com>
  15. */
  16. interface ICommand
  17. {
  18. /**
  19. * Gets the ID of a Redis command.
  20. *
  21. * @return string
  22. */
  23. public function getId();
  24. /**
  25. * Returns an hash of the command using the provided algorithm against the
  26. * key (used to calculate the distribution of keys with client-side sharding).
  27. *
  28. * @param INodeKeyGenerator $distributor Distribution algorithm.
  29. * @return int
  30. */
  31. public function getHash(INodeKeyGenerator $distributor);
  32. /**
  33. * Sets the arguments of the command.
  34. *
  35. * @param array $arguments List of arguments.
  36. */
  37. public function setArguments(Array $arguments);
  38. /**
  39. * Gets the arguments of the command.
  40. *
  41. * @return array
  42. */
  43. public function getArguments();
  44. /**
  45. * Prefixes all the keys in the arguments of the command.
  46. *
  47. * @param string $prefix String user to prefix the keys.
  48. */
  49. public function prefixKeys($prefix);
  50. /**
  51. * Parses a reply buffer and returns a PHP object.
  52. *
  53. * @param string $data Binary string containing the whole reply.
  54. * @return mixed
  55. */
  56. public function parseResponse($data);
  57. }