mirror of
https://github.com/idanoo/php-resque
synced 2025-07-02 22:22:21 +00:00
Added remove_queue command from Resque
This commit is contained in:
parent
eb7ab0c81a
commit
f29e09d68b
1 changed files with 16 additions and 3 deletions
|
@ -143,6 +143,19 @@ class Resque
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove specified queue
|
||||||
|
*
|
||||||
|
* @param string $queue The name of the queue to remove.
|
||||||
|
* @return integer number of deleted items
|
||||||
|
*/
|
||||||
|
public static function removeQueue($queue)
|
||||||
|
{
|
||||||
|
$num = self::removeList($queue);
|
||||||
|
self::redis()->srem('queues', $queue);
|
||||||
|
return $num;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pop an item off the end of the specified queues, using blocking list pop,
|
* Pop an item off the end of the specified queues, using blocking list pop,
|
||||||
* decode it and return it.
|
* decode it and return it.
|
||||||
|
@ -264,12 +277,12 @@ class Resque
|
||||||
$originalQueue = 'queue:'. $queue;
|
$originalQueue = 'queue:'. $queue;
|
||||||
$tempQueue = $originalQueue. ':temp:'. time();
|
$tempQueue = $originalQueue. ':temp:'. time();
|
||||||
$requeueQueue = $tempQueue. ':requeue';
|
$requeueQueue = $tempQueue. ':requeue';
|
||||||
|
|
||||||
// move each item from original queue to temp queue and process it
|
// move each item from original queue to temp queue and process it
|
||||||
$finished = false;
|
$finished = false;
|
||||||
while (!$finished) {
|
while (!$finished) {
|
||||||
$string = self::redis()->rpoplpush($originalQueue, self::redis()->getPrefix() . $tempQueue);
|
$string = self::redis()->rpoplpush($originalQueue, self::redis()->getPrefix() . $tempQueue);
|
||||||
|
|
||||||
if (!empty($string)) {
|
if (!empty($string)) {
|
||||||
if(self::matchItem($string, $items)) {
|
if(self::matchItem($string, $items)) {
|
||||||
self::redis()->rpop($tempQueue);
|
self::redis()->rpop($tempQueue);
|
||||||
|
@ -294,7 +307,7 @@ class Resque
|
||||||
// remove temp queue and requeue queue
|
// remove temp queue and requeue queue
|
||||||
self::redis()->del($requeueQueue);
|
self::redis()->del($requeueQueue);
|
||||||
self::redis()->del($tempQueue);
|
self::redis()->del($tempQueue);
|
||||||
|
|
||||||
return $counter;
|
return $counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue