diff --git a/lib/Redis.php b/lib/Redis.php index 7d946a5..b7795c0 100644 --- a/lib/Redis.php +++ b/lib/Redis.php @@ -125,7 +125,7 @@ public static function prefix($namespace) * DSN-supplied value will be used instead and this parameter is ignored. * @param object $client Optional Credis_Cluster or Credis_Client instance instantiated by you */ - public function __construct($server, $database = null, $client = null) + public function __construct($server, $database = null, $client = null, $auth = null) { try { if (is_object($client)) { @@ -146,7 +146,7 @@ public function __construct($server, $database = null, $client = null) $this->driver = new Credis_Client($host, $port, $timeout, $persistent); $this->driver->setMaxConnectRetries($maxRetries); if ($password) { - $this->driver->auth($password); + $auth = $password; } // If we have found a database in our DSN, use it instead of the `$database` @@ -156,6 +156,10 @@ public function __construct($server, $database = null, $client = null) } } + if ($auth !== null) { + $this->driver->auth($auth); + } + if ($database !== null) { $this->driver->select($database); } diff --git a/lib/Resque.php b/lib/Resque.php index f47a630..af69c21 100644 --- a/lib/Resque.php +++ b/lib/Resque.php @@ -72,7 +72,7 @@ public static function redis() if (is_callable(self::$redisServer)) { self::$redis = call_user_func(self::$redisServer, self::$redisDatabase); } else { - self::$redis = new Redis(self::$redisServer, self::$redisDatabase); + self::$redis = new Redis(self::$redisServer, self::$redisDatabase, null, self::$auth); } if (!empty(self::$auth)) {