StrategyInterface.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 out of
  14. * 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 StrategyInterface
  21. {
  22. /**
  23. * Returns the hash for the given command using the specified algorithm, or
  24. * null when the command cannot be hashed.
  25. *
  26. * @param CommandInterface $command Command instance.
  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 string.
  34. * @return string
  35. */
  36. public function getKeyHash($key);
  37. }