client.rst 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. The `Predis\\Client` class
  2. --------------------------
  3. .. php:namespace:: Predis
  4. The `Client` class is the main class users interact with in Predis. The first
  5. thing you'll do to start communicating with Redis is instantiate a `Client`.
  6. Constructing a Client
  7. =====================
  8. The `Client` constructor takes two arguments. The first (``$parameters``) is a
  9. set of information about the Redis connection you'd like to make. The second
  10. (``$options``) is a set of options to configure the client.
  11. .. php:class:: Client
  12. .. php:method:: __construct($parameters = null, $options = null)
  13. Creates a new `Client` instance.
  14. :param $parameters: Connection parameters
  15. :param $options: Client options
  16. Connection Parameters
  17. '''''''''''''''''''''
  18. These parameters are used to control the behaviour of the underlying connection
  19. to Redis. They can be specified using a URI string::
  20. $client = new Predis\Client('tcp://127.0.0.1:6379?database=2')
  21. Or, using an associative array::
  22. $client = new Predis\Client(array(
  23. 'scheme' => 'tcp',
  24. 'host' => '127.0.0.1',
  25. 'port' => 6379,
  26. 'database' => 3
  27. ));
  28. Client Options
  29. ''''''''''''''