DistributionStrategyInterface.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. * @param mixed $key
  37. * @return mixed
  38. */
  39. public function get($key);
  40. /**
  41. * Returns the underlying hash generator instance.
  42. *
  43. * @return HashGeneratorInterface
  44. */
  45. public function getHashGenerator();
  46. }