mirror of
https://github.com/idanoo/php-resque.git
synced 2024-11-25 09:45:15 +00:00
Merge pull request #89 from trimbletodd/master
Adding support for remote redis instances (such as redistogo) that require authentication
This commit is contained in:
commit
4cbf3c08c2
@ -101,6 +101,7 @@ class Resque_Redis
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$port = null;
|
$port = null;
|
||||||
|
$password = null;
|
||||||
$host = $server;
|
$host = $server;
|
||||||
|
|
||||||
// If not a UNIX socket path or tcp:// formatted connections string
|
// If not a UNIX socket path or tcp:// formatted connections string
|
||||||
@ -111,8 +112,19 @@ class Resque_Redis
|
|||||||
$port = $parts[1];
|
$port = $parts[1];
|
||||||
}
|
}
|
||||||
$host = $parts[0];
|
$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);
|
$this->driver = new Credis_Client($host, $port);
|
||||||
|
if (isset($password)){
|
||||||
|
$this->driver->auth($password);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->database !== null) {
|
if ($this->database !== null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user