From 097ae101ae42508e456a606a65f8b953795c3620 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 3 Nov 2015 05:09:57 -0800 Subject: [PATCH] Convert JobQueueGroup::getCachedConfigVar to using WAN cache Change-Id: I793ab8c11698a1c6f6c3bdd20c61b3645ca5d544 --- includes/jobqueue/JobQueueGroup.php | 33 +++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/includes/jobqueue/JobQueueGroup.php b/includes/jobqueue/JobQueueGroup.php index 4609d2d37e..d6247cbf9b 100644 --- a/includes/jobqueue/JobQueueGroup.php +++ b/includes/jobqueue/JobQueueGroup.php @@ -381,27 +381,24 @@ class JobQueueGroup { * @return mixed */ private function getCachedConfigVar( $name ) { - global $wgConf; - + // @TODO: cleanup this whole method with a proper config system if ( $this->wiki === wfWikiID() ) { return $GLOBALS[$name]; // common case } else { - $cache = ObjectCache::getLocalClusterInstance(); - list( $db, $prefix ) = wfSplitWikiID( $this->wiki ); - $key = wfForeignMemcKey( $db, $prefix, 'configvalue', $name ); - $value = $cache->get( $key ); // ('v' => ...) or false - if ( is_array( $value ) ) { - return $value['v']; - } else { - $value = $wgConf->getConfig( $this->wiki, $name ); - $cache->set( - $key, - array( 'v' => $value ), - $cache::TTL_DAY + mt_rand( 0, $cache::TTL_DAY ) - ); - - return $value; - } + $wiki = $this->wiki; + $cache = ObjectCache::getMainWANInstance(); + $value = $cache->getWithSetCallback( + $cache->makeGlobalKey( 'jobqueue', 'configvalue', $wiki, $name ), + $cache::TTL_DAY + mt_rand( 0, $cache::TTL_DAY ), + function () use ( $wiki, $name ) { + global $wgConf; + + return array( 'v' => $wgConf->getConfig( $wiki, $name ) ); + }, + array( 'pcTTL' => 30 ) + ); + + return $value['v']; } } -- 2.20.1