mirror of
https://github.com/idanoo/php-resque.git
synced 2024-11-22 00:11:53 +00:00
Merge pull request #214 from bc-vincent-zhao/allow-callable-redis-setup
Allows a callable to be passed to Resque::setBackend for setting the redis instance
This commit is contained in:
commit
c335bc3555
@ -33,6 +33,8 @@ class Resque
|
||||
* the redis server that Resque will talk to.
|
||||
*
|
||||
* @param mixed $server Host/port combination separated by a colon, DSN-formatted URI, or
|
||||
* a callable that receives the configured database ID
|
||||
* and returns a Resque_Redis instance, or
|
||||
* a nested array of servers with host/port pairs.
|
||||
* @param int $database
|
||||
*/
|
||||
@ -54,7 +56,12 @@ class Resque
|
||||
return self::$redis;
|
||||
}
|
||||
|
||||
self::$redis = new Resque_Redis(self::$redisServer, self::$redisDatabase);
|
||||
if (is_callable(self::$redisServer)) {
|
||||
self::$redis = call_user_func(self::$redisServer, self::$redisDatabase);
|
||||
} else {
|
||||
self::$redis = new Resque_Redis(self::$redisServer, self::$redisDatabase);
|
||||
}
|
||||
|
||||
return self::$redis;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user