[JobQueue] Added a function to delete all jobs from a queue.
[lhc/web/wiklou.git] / includes / job / JobQueueRedis.php
index 249ba27..8250d2b 100644 (file)
@@ -484,6 +484,26 @@ LUA;
                return ( $timestamp && $timestamp > $params['rootJobTimestamp'] );
        }
 
+       /**
+        * @see JobQueue::doDelete()
+        * @return bool
+        */
+       protected function doDelete() {
+               static $props = array( 'l-unclaimed', 'z-claimed', 'z-abandoned',
+                       'z-delayed', 'h-idBySha1', 'h-sha1ById', 'h-attempts', 'h-data' );
+
+               $conn = $this->getConnection();
+               try {
+                       $keys = array();
+                       foreach ( $props as $prop ) {
+                               $keys[] = $this->getQueueKey( $prop );
+                       }
+                       $res = ( $conn->delete( $keys ) !== false );
+               } catch ( RedisException $e ) {
+                       $this->throwRedisException( $this->server, $conn, $e );
+               }
+       }
+
        /**
         * @see JobQueue::getAllQueuedJobs()
         * @return Iterator