IConnectionReplication.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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\Network;
  11. use Predis\Commands\ICommand;
  12. /**
  13. * Defines a group of Redis servers in a master/slave replication configuration.
  14. *
  15. * @author Daniele Alessandri <suppakilla@gmail.com>
  16. */
  17. interface IConnectionReplication extends IConnection
  18. {
  19. /**
  20. * Adds a connection instance to the cluster.
  21. *
  22. * @param IConnectionSingle $connection Instance of a connection.
  23. */
  24. public function add(IConnectionSingle $connection);
  25. /**
  26. * Removes the specified connection instance from the cluster.
  27. *
  28. * @param IConnectionSingle $connection Instance of a connection.
  29. * @return Boolean Returns true if the connection was in the pool.
  30. */
  31. public function remove(IConnectionSingle $connection);
  32. /**
  33. * Gets the actual connection instance in charge of the specified command.
  34. *
  35. * @param ICommand $command Instance of a Redis command.
  36. * @return IConnectionSingle
  37. */
  38. public function getConnection(ICommand $command);
  39. /**
  40. * Retrieves a connection instance from the cluster using an alias.
  41. *
  42. * @param string $connectionId Alias of a connection
  43. * @return IConnectionSingle
  44. */
  45. public function getConnectionById($connectionId);
  46. /**
  47. * Switches the internal connection object being used.
  48. *
  49. * @param string $connection Alias of a connection
  50. */
  51. public function switchTo($connection);
  52. /**
  53. * Retrieves the connection object currently being used.
  54. *
  55. * @return IConnectionSingle
  56. */
  57. public function getCurrent();
  58. /**
  59. * Retrieves the connection object to the master Redis server.
  60. *
  61. * @return IConnectionSingle
  62. */
  63. public function getMaster();
  64. /**
  65. * Retrieves a list of connection objects to slaves Redis servers.
  66. *
  67. * @return IConnectionSingle
  68. */
  69. public function getSlaves();
  70. }