IDistributionStrategy.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\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 IDistributionStrategy extends INodeKeyGenerator
  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. }