IConnectionFactory.php 1.7 KB

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