CommandHashStrategyInterface.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\Command\Hash;
  11. use Predis\Command\CommandInterface;
  12. use Predis\Distribution\HashGeneratorInterface;
  13. /**
  14. * Interface for classes defining the strategy used to calculate an hash
  15. * out of keys extracted from supported commands.
  16. *
  17. * This is mostly useful to support clustering via client-side sharding.
  18. *
  19. * @author Daniele Alessandri <suppakilla@gmail.com>
  20. */
  21. interface CommandHashStrategyInterface
  22. {
  23. /**
  24. * Returns the hash for the given command using the specified algorithm, or null
  25. * if the command cannot be hashed.
  26. *
  27. * @param CommandInterface $command Command to be hashed.
  28. * @return int
  29. */
  30. public function getHash(CommandInterface $command);
  31. /**
  32. * Returns the hash for the given key using the specified algorithm.
  33. *
  34. * @param string $key Key to be hashed.
  35. * @return string
  36. */
  37. public function getKeyHash($key);
  38. }