X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSiteStats.php;h=6a2d0e2adada89fe64ed1bbf65da995ff814fdc0;hb=cd4130790a4a72de7c5b3a81399de0c3f0c66d03;hp=df3e305c271407e2a16350cdfc46a448de1d5009;hpb=244e29b2c9e0b68c1fcbaab2f20364860d9c58ff;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SiteStats.php b/includes/SiteStats.php index df3e305c27..6a2d0e2ada 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -34,9 +34,6 @@ class SiteStats { /** @var bool */ private static $loaded = false; - /** @var int */ - private static $jobs; - /** @var int[] */ private static $pageCount = []; @@ -213,17 +210,24 @@ class SiteStats { } /** + * Total number of jobs in the job queue. * @return int */ static function jobs() { - if ( !isset( self::$jobs ) ) { - try{ - self::$jobs = array_sum( JobQueueGroup::singleton()->getQueueSizes() ); - } catch ( JobQueueError $e ) { - self::$jobs = 0; - } - } - return self::$jobs; + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + return $cache->getWithSetCallback( + $cache->makeKey( 'SiteStats', 'jobscount' ), + $cache::TTL_MINUTE, + function ( $oldValue, &$ttl, array &$setOpts ) { + try{ + $jobs = array_sum( JobQueueGroup::singleton()->getQueueSizes() ); + } catch ( JobQueueError $e ) { + $jobs = 0; + } + return $jobs; + }, + [ 'pcTTL' => $cache::TTL_PROC_LONG ] + ); } /**