CommandHashStrategyInterface.php 1.1 KB

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