[JobQueue] Added a function to purge the aggregator cache.
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 14 Mar 2013 20:03:13 +0000 (13:03 -0700)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 27 Mar 2013 04:33:52 +0000 (04:33 +0000)
Change-Id: If9eabf202c372d5c594f5faeb75265ff78104f7f

includes/job/JobQueueAggregator.php
includes/job/JobQueueAggregatorMemc.php
includes/job/JobQueueAggregatorRedis.php

index 3dba3c5..a8186ab 100644 (file)
@@ -118,6 +118,23 @@ abstract class JobQueueAggregator {
         */
        abstract protected function doGetAllReadyWikiQueues();
 
+       /**
+        * Purge all of the aggregator information
+        *
+        * @return bool Success
+        */
+       final public function purge() {
+               wfProfileIn( __METHOD__ );
+               $res = $this->doPurge();
+               wfProfileOut( __METHOD__ );
+               return $res;
+       }
+
+       /**
+        * @see JobQueueAggregator::purge()
+        */
+       abstract protected function doPurge();
+
        /**
         * Get all databases that have a pending job.
         * This poll all the queues and is this expensive.
index 4b82cf9..15bb833 100644 (file)
@@ -108,6 +108,13 @@ class JobQueueAggregatorMemc extends JobQueueAggregator {
                        : array(); // cache is both empty and locked
        }
 
+       /**
+        * @see JobQueueAggregator::doPurge()
+        */
+       protected function doPurge() {
+               return $this->cache->delete( $this->getReadyQueueCacheKey() );
+       }
+
        /**
         * @return string
         */
index 512a24a..aae800e 100644 (file)
@@ -120,6 +120,23 @@ class JobQueueAggregatorRedis extends JobQueueAggregator {
                }
        }
 
+       /**
+        * @see JobQueueAggregator::doPurge()
+        */
+       protected function doPurge() {
+               $conn = $this->getConnection();
+               if ( !$conn ) {
+                       return false;
+               }
+               try {
+                       $conn->delete( $this->getReadyQueueKey() );
+               } catch ( RedisException $e ) {
+                       $this->handleException( $conn, $e );
+                       return false;
+               }
+               return true;
+       }
+
        /**
         * Get a connection to the server that handles all sub-queues for this queue
         *