From 6a429c2f21174b5429f56871af22c07d19616291 Mon Sep 17 00:00:00 2001 From: TrimbleTodd Date: Wed, 20 Feb 2013 11:41:41 -0500 Subject: [PATCH] adding support for remote redis instances (such as redistogo) that require authentication --- lib/Resque/Redis.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Resque/Redis.php b/lib/Resque/Redis.php index f6f6dc6..bbb0643 100644 --- a/lib/Resque/Redis.php +++ b/lib/Resque/Redis.php @@ -101,6 +101,7 @@ class Resque_Redis } else { $port = null; + $password = null; $host = $server; // If not a UNIX socket path or tcp:// formatted connections string @@ -111,8 +112,19 @@ class Resque_Redis $port = $parts[1]; } $host = $parts[0]; + }else if (strpos($server, 'redis://') !== false){ + // Redis format is: + // redis://[user]:[password]@[host]:[port] + list($userpwd,$hostport) = explode('@', $server); + $userpwd = substr($userpwd, strpos($userpwd, 'redis://')+8); + list($host, $port) = explode(':', $hostport); + list($user, $password) = explode(':', $userpwd); } + $this->driver = new Credis_Client($host, $port); + if (isset($password)){ + $this->driver->auth($password); + } } if ($this->database !== null) {