From d5aed5820d8813b56cf2f8a81693c51a1bad7566 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 14 Mar 2013 13:03:13 -0700 Subject: [PATCH] [JobQueue] Added a function to purge the aggregator cache. Change-Id: If9eabf202c372d5c594f5faeb75265ff78104f7f --- includes/job/JobQueueAggregator.php | 17 +++++++++++++++++ includes/job/JobQueueAggregatorMemc.php | 7 +++++++ includes/job/JobQueueAggregatorRedis.php | 17 +++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/includes/job/JobQueueAggregator.php b/includes/job/JobQueueAggregator.php index 3dba3c535d..a8186abd4d 100644 --- a/includes/job/JobQueueAggregator.php +++ b/includes/job/JobQueueAggregator.php @@ -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. diff --git a/includes/job/JobQueueAggregatorMemc.php b/includes/job/JobQueueAggregatorMemc.php index 4b82cf925a..15bb833208 100644 --- a/includes/job/JobQueueAggregatorMemc.php +++ b/includes/job/JobQueueAggregatorMemc.php @@ -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 */ diff --git a/includes/job/JobQueueAggregatorRedis.php b/includes/job/JobQueueAggregatorRedis.php index 512a24a521..aae800ebf0 100644 --- a/includes/job/JobQueueAggregatorRedis.php +++ b/includes/job/JobQueueAggregatorRedis.php @@ -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 * -- 2.20.1