DistributionStrategyInterface.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\Distribution;
  11. use Predis\Cluster\Hash\HashGeneratorInterface;
  12. /**
  13. * A distributor implements the logic to automatically distribute
  14. * keys among several nodes for client-side sharding.
  15. *
  16. * @author Daniele Alessandri <suppakilla@gmail.com>
  17. */
  18. interface DistributionStrategyInterface
  19. {
  20. /**
  21. * Adds a node to the distributor with an optional weight.
  22. *
  23. * @param mixed $node Node object.
  24. * @param int $weight Weight for the node.
  25. */
  26. public function add($node, $weight = null);
  27. /**
  28. * Removes a node from the distributor.
  29. *
  30. * @param mixed $node Node object.
  31. */
  32. public function remove($node);
  33. /**
  34. * Gets a node from the distributor using the computed hash of a key.
  35. *
  36. * @return mixed
  37. */
  38. public function get($key);
  39. /**
  40. * Returns the underlying hash generator instance.
  41. *
  42. * @return HashGeneratorInterface
  43. */
  44. public function getHashGenerator();
  45. }