IConnectionFactory.php 2.1 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;
  11. use Predis\Profiles\IServerProfile;
  12. use Predis\Network\IConnectionCluster;
  13. use Predis\Network\IConnectionReplication;
  14. /**
  15. * Interface that must be implemented by classes that provide their own mechanism
  16. * to create and initialize new instances of Predis\Network\IConnectionSingle.
  17. *
  18. * @author Daniele Alessandri <suppakilla@gmail.com>
  19. */
  20. interface IConnectionFactory
  21. {
  22. /**
  23. * Defines or overrides the connection class identified by a scheme prefix.
  24. *
  25. * @param string $scheme URI scheme identifying the connection class.
  26. * @param mixed $initializer FQN of a connection class or a callable object for lazy initialization.
  27. */
  28. public function define($scheme, $initializer);
  29. /**
  30. * Undefines the connection identified by a scheme prefix.
  31. *
  32. * @param string $scheme Parameters for the connection.
  33. */
  34. public function undefine($scheme);
  35. /**
  36. * Creates a new connection object.
  37. *
  38. * @param mixed $parameters Parameters for the connection.
  39. * @return Predis\Network\IConnectionSingle
  40. */
  41. public function create($parameters, IServerProfile $profile = null);
  42. /**
  43. * Prepares a cluster of connection objects.
  44. *
  45. * @param IConnectionCluster Instance of a connection cluster class.
  46. * @param array $parameters List of parameters for each connection object.
  47. * @return Predis\Network\IConnectionCluster
  48. */
  49. public function createCluster(IConnectionCluster $cluster, $parameters, IServerProfile $profile = null);
  50. /**
  51. * Prepares a master / slave replication configuration.
  52. *
  53. * @param IConnectionReplication Instance of a connection cluster class.
  54. * @param array $parameters List of parameters for each connection object.
  55. * @return Predis\Network\IConnectionReplication
  56. */
  57. public function createReplication(IConnectionReplication $replication, $parameters, IServerProfile $profile = null);
  58. }