From c9ceccc196bec331b72da19a84c2a7675b799c68 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 24 May 2015 00:59:49 -0700 Subject: [PATCH] Process cache tagUsageStatistics() to improve performance Change-Id: I4a95c00d84c216ad08f30f0971877dfb728f86ff --- includes/changetags/ChangeTags.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index a730116679..79763bd2d3 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -1177,9 +1177,15 @@ class ChangeTags { * @return array Array of string => int */ public static function tagUsageStatistics() { - $fname = __METHOD__; + static $cachedStats = null; - return ObjectCache::getMainWANInstance()->getWithSetCallback( + // Process cache to avoid I/O and repeated regens during holdoff + if ( $cachedStats !== null ) { + return $cachedStats; + } + + $fname = __METHOD__; + $cachedStats = ObjectCache::getMainWANInstance()->getWithSetCallback( wfMemcKey( 'change-tag-statistics' ), function() use ( $fname ) { $out = array(); @@ -1209,6 +1215,8 @@ class ChangeTags { array( wfMemcKey( 'change-tag-statistics' ) ), array( 'lockTSE' => INF ) ); + + return $cachedStats; } /** -- 2.20.1