@@ -143,6 +143,19 @@ public static function dequeue($queue, $items = Array())
143
143
}
144
144
}
145
145
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
+
146
159
/**
147
160
* Pop an item off the end of the specified queues, using blocking list pop,
148
161
* decode it and return it.
@@ -264,12 +277,12 @@ private static function removeItems($queue, $items = Array())
264
277
$ originalQueue = 'queue: ' . $ queue ;
265
278
$ tempQueue = $ originalQueue . ':temp: ' . time ();
266
279
$ requeueQueue = $ tempQueue . ':requeue ' ;
267
-
280
+
268
281
// move each item from original queue to temp queue and process it
269
282
$ finished = false ;
270
283
while (!$ finished ) {
271
284
$ string = self ::redis ()->rpoplpush ($ originalQueue , self ::redis ()->getPrefix () . $ tempQueue );
272
-
285
+
273
286
if (!empty ($ string )) {
274
287
if (self ::matchItem ($ string , $ items )) {
275
288
self ::redis ()->rpop ($ tempQueue );
@@ -294,7 +307,7 @@ private static function removeItems($queue, $items = Array())
294
307
// remove temp queue and requeue queue
295
308
self ::redis ()->del ($ requeueQueue );
296
309
self ::redis ()->del ($ tempQueue );
297
-
310
+
298
311
return $ counter ;
299
312
}
300
313
0 commit comments