Browse Source

Made the constructor method of Predis\Client more flexible with the passed arguments.

Daniele Alessandri 15 years ago
parent
commit
6bd7ef9217
1 changed files with 6 additions and 2 deletions
  1. 6 2
      lib/Predis.php

+ 6 - 2
lib/Predis.php

@@ -17,9 +17,13 @@ class Client {
 
     public function __construct($host = Connection::DEFAULT_HOST, $port = Connection::DEFAULT_PORT) {
         $this->_pipelining = false;
-        $connectionParams  = new ConnectionParameters(array('host' => $host, 'port' => $port));
-        $this->_connection = new Connection($connectionParams);
         $this->_registeredCommands = self::initializeDefaultCommands();
+
+        $this->setConnection($this->createConnection(
+            func_num_args() === 1 && is_array($host) || @stripos('redis://') === 0
+                ? $host
+                : array('host' => $host, 'port' => $port)
+        ));
     }
 
     public function __destruct() {