ConnectionFactoryInterface.php 2.3 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\Profile\ServerProfileInterface;
  12. use Predis\Connection\ClusterConnectionInterface;
  13. use Predis\Connection\ReplicationConnectionInterface;
  14. /**
  15. * Interface that must be implemented by classes that provide their own mechanism
  16. * to create and initialize new instances of Predis\Connection\SingleConnectionInterface.
  17. *
  18. * @author Daniele Alessandri <suppakilla@gmail.com>
  19. */
  20. interface ConnectionFactoryInterface
  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\Connection\SingleConnectionInterface
  40. */
  41. public function create($parameters, ServerProfileInterface $profile = null);
  42. /**
  43. * Prepares a cluster of connection objects.
  44. *
  45. * @param ClusterConnectionInterface Instance of a connection cluster class.
  46. * @param array $parameters List of parameters for each connection object.
  47. * @return Predis\Connection\ClusterConnectionInterface
  48. */
  49. public function createCluster(ClusterConnectionInterface $cluster, $parameters, ServerProfileInterface $profile = null);
  50. /**
  51. * Prepares a master / slave replication configuration.
  52. *
  53. * @param ReplicationConnectionInterface Instance of a connection cluster class.
  54. * @param array $parameters List of parameters for each connection object.
  55. * @return Predis\Connection\ReplicationConnectionInterface
  56. */
  57. public function createReplication(ReplicationConnectionInterface $replication, $parameters, ServerProfileInterface $profile = null);
  58. }