Permalink
Browse files

adding support for remote redis instances (such as redistogo) that re…

…quire authentication
  • Loading branch information...
1 parent 9b45f15 commit 6a429c2f21174b5429f56871af22c07d19616291 @trimbletodd trimbletodd committed Feb 20, 2013
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/Resque/Redis.php
View
@@ -101,6 +101,7 @@ public function __construct($server, $database = null)
}
else {
$port = null;
+ $password = null;
$host = $server;
// If not a UNIX socket path or tcp:// formatted connections string
@@ -111,8 +112,19 @@ public function __construct($server, $database = null)
$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) {

0 comments on commit 6a429c2

Please sign in to comment.