ConnectionInterface.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\Connection;
  11. use Predis\Command\CommandInterface;
  12. /**
  13. * Defines a connection object used to communicate with one or multiple
  14. * Redis servers.
  15. *
  16. * @author Daniele Alessandri <suppakilla@gmail.com>
  17. */
  18. interface ConnectionInterface
  19. {
  20. /**
  21. * Opens the connection to Redis.
  22. */
  23. public function connect();
  24. /**
  25. * Closes the connection to Redis.
  26. */
  27. public function disconnect();
  28. /**
  29. * Checks if the connection to Redis is considered open.
  30. *
  31. * @return bool
  32. */
  33. public function isConnected();
  34. /**
  35. * Writes the request for the given command over the connection.
  36. *
  37. * @param CommandInterface $command Command instance.
  38. */
  39. public function writeRequest(CommandInterface $command);
  40. /**
  41. * Reads the response to the given command from the connection.
  42. *
  43. * @param CommandInterface $command Command instance.
  44. *
  45. * @return mixed
  46. */
  47. public function readResponse(CommandInterface $command);
  48. /**
  49. * Writes a request for the given command over the connection and reads back
  50. * the response returned by Redis.
  51. *
  52. * @param CommandInterface $command Command instance.
  53. *
  54. * @return mixed
  55. */
  56. public function executeCommand(CommandInterface $command);
  57. }