Skip to content

Commit f29e09d

Browse files
committed
Added remove_queue command from Resque
1 parent eb7ab0c commit f29e09d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lib/Resque.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ public static function dequeue($queue, $items = Array())
143143
}
144144
}
145145

146+
/**
147+
* Remove specified queue
148+
*
149+
* @param string $queue The name of the queue to remove.
150+
* @return integer number of deleted items
151+
*/
152+
public static function removeQueue($queue)
153+
{
154+
$num = self::removeList($queue);
155+
self::redis()->srem('queues', $queue);
156+
return $num;
157+
}
158+
146159
/**
147160
* Pop an item off the end of the specified queues, using blocking list pop,
148161
* decode it and return it.
@@ -264,12 +277,12 @@ private static function removeItems($queue, $items = Array())
264277
$originalQueue = 'queue:'. $queue;
265278
$tempQueue = $originalQueue. ':temp:'. time();
266279
$requeueQueue = $tempQueue. ':requeue';
267-
280+
268281
// move each item from original queue to temp queue and process it
269282
$finished = false;
270283
while (!$finished) {
271284
$string = self::redis()->rpoplpush($originalQueue, self::redis()->getPrefix() . $tempQueue);
272-
285+
273286
if (!empty($string)) {
274287
if(self::matchItem($string, $items)) {
275288
self::redis()->rpop($tempQueue);
@@ -294,7 +307,7 @@ private static function removeItems($queue, $items = Array())
294307
// remove temp queue and requeue queue
295308
self::redis()->del($requeueQueue);
296309
self::redis()->del($tempQueue);
297-
310+
298311
return $counter;
299312
}
300313

0 commit comments

Comments
 (0)