From f29e09d68b18fa22296f78ed2a5c9276a80e3381 Mon Sep 17 00:00:00 2001 From: Dan Rahmel Date: Fri, 13 Mar 2015 14:49:30 -0700 Subject: [PATCH] Added remove_queue command from Resque --- lib/Resque.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/Resque.php b/lib/Resque.php index efe7f25..09e0166 100644 --- a/lib/Resque.php +++ b/lib/Resque.php @@ -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, * decode it and return it. @@ -264,12 +277,12 @@ class Resque $originalQueue = 'queue:'. $queue; $tempQueue = $originalQueue. ':temp:'. time(); $requeueQueue = $tempQueue. ':requeue'; - + // move each item from original queue to temp queue and process it $finished = false; while (!$finished) { $string = self::redis()->rpoplpush($originalQueue, self::redis()->getPrefix() . $tempQueue); - + if (!empty($string)) { if(self::matchItem($string, $items)) { self::redis()->rpop($tempQueue); @@ -294,7 +307,7 @@ class Resque // remove temp queue and requeue queue self::redis()->del($requeueQueue); self::redis()->del($tempQueue); - + return $counter; }