@@ -33,6 +33,8 @@ class Resque
33
33
* the redis server that Resque will talk to.
34
34
*
35
35
* @param mixed $server Host/port combination separated by a colon, DSN-formatted URI, or
36
+ * a callable that receives the configured database ID
37
+ * and returns a Resque_Redis instance, or
36
38
* a nested array of servers with host/port pairs.
37
39
* @param int $database
38
40
*/
@@ -54,10 +56,15 @@ public static function redis()
54
56
return self ::$ redis ;
55
57
}
56
58
57
- self ::$ redis = new Resque_Redis (self ::$ redisServer , self ::$ redisDatabase );
59
+ if (is_callable (self ::$ redisServer )) {
60
+ self ::$ redis = call_user_func (self ::$ redisServer , self ::$ redisDatabase );
61
+ } else {
62
+ self ::$ redis = new Resque_Redis (self ::$ redisServer , self ::$ redisDatabase );
63
+ }
64
+
58
65
return self ::$ redis ;
59
66
}
60
-
67
+
61
68
/**
62
69
* fork() helper method for php-resque that handles issues PHP socket
63
70
* and phpredis have with passing around sockets between child/parent
@@ -135,7 +142,7 @@ public static function dequeue($queue, $items = Array())
135
142
return self ::removeList ($ queue );
136
143
}
137
144
}
138
-
145
+
139
146
/**
140
147
* Pop an item off the end of the specified queues, using blocking list pop,
141
148
* decode it and return it.
@@ -324,7 +331,7 @@ private static function matchItem($string, $items)
324
331
* Remove List
325
332
*
326
333
* @private
327
- *
334
+ *
328
335
* @params string $queue the name of the queue
329
336
* @return integer number of deleted items belongs to this list
330
337
*/
0 commit comments