/** @var bool */
private static $loaded = false;
- /** @var int */
- private static $jobs;
-
/** @var int[] */
private static $pageCount = [];
* @return int
*/
static function numberingroup( $group ) {
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback(
- wfMemcKey( 'SiteStats', 'groupcounts', $group ),
+ $cache->makeKey( 'SiteStats', 'groupcounts', $group ),
$cache::TTL_HOUR,
function ( $oldValue, &$ttl, array &$setOpts ) use ( $group ) {
$dbr = wfGetDB( DB_REPLICA );
}
/**
+ * 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;
- }
- /**
- * Zero rows still do single row read for row that doesn't exist,
- * but people are annoyed by that
- */
- if ( self::$jobs == 1 ) {
- 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 ]
+ );
}
/**
private $mUsers = null, $mFiles = null;
/**
- * Constructor
* @param bool|IDatabase $database
* - boolean: Whether to use the master DB
* - IDatabase: Database connection to use