From: Aaron Schulz Date: Thu, 14 Mar 2013 20:03:13 +0000 (-0700) Subject: [JobQueue] Added a function to purge the aggregator cache. X-Git-Tag: 1.31.0-rc.0~20213 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=d5aed5820d8813b56cf2f8a81693c51a1bad7566;p=lhc%2Fweb%2Fwiklou.git [JobQueue] Added a function to purge the aggregator cache. Change-Id: If9eabf202c372d5c594f5faeb75265ff78104f7f --- 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 *