mirror of
https://github.com/idanoo/php-resque
synced 2025-07-01 13:42:22 +00:00
WIP
This commit is contained in:
parent
e541fa9b70
commit
b8f98eecd2
7 changed files with 150 additions and 102 deletions
|
@ -114,21 +114,40 @@ class Resque
|
|||
* @param string $queue The name of the queue to fetch an item from.
|
||||
* @return array Decoded item from the queue.
|
||||
*/
|
||||
public static function pop($queue, $interval = null)
|
||||
public static function pop($queue)
|
||||
{
|
||||
if($interval == null) {
|
||||
$item = self::redis()->lpop('queue:' . $queue);
|
||||
} else {
|
||||
$item = self::redis()->blpop('queue:' . $queue, $interval ? $interval : Resque::DEFAULT_INTERVAL);
|
||||
}
|
||||
$item = self::redis()->lpop('queue:' . $queue);
|
||||
|
||||
if(!$item) {
|
||||
return;
|
||||
}
|
||||
|
||||
return json_decode($interval == 0 ? $item : $item[1], true);
|
||||
return json_decode($item, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop an item off the end of the specified queue, decode it and
|
||||
* return it.
|
||||
*
|
||||
* @param string $queue The name of the queue to fetch an item from.
|
||||
* @return array Decoded item from the queue.
|
||||
*/
|
||||
public static function blpop($queues, $interval = null)
|
||||
{
|
||||
$list = array();
|
||||
foreach($queues AS $queue) {
|
||||
$list[] = 'queue:' . $queue;
|
||||
}
|
||||
|
||||
$item = self::redis()->blpop($list, $interval ? (int)$interval : Resque::DEFAULT_INTERVAL);
|
||||
|
||||
if(!$item) {
|
||||
return;
|
||||
}
|
||||
|
||||
return json_decode($item[1], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the size (number of pending jobs) of the specified queue.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue