DistributionStrategyInterface.php 1.2 KB

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