* @return int
*/
static function numberingroup( $group ) {
- if ( !isset( self::$groupMemberCounts[$group] ) ) {
- global $wgMemc;
- $key = wfMemcKey( 'SiteStats', 'groupcounts', $group );
- $hit = $wgMemc->get( $key );
- if ( !$hit ) {
+ $cache = ObjectCache::getMainWANInstance();
+ return $cache->getWithSetCallback(
+ wfMemcKey( 'SiteStats', 'groupcounts', $group ),
+ $cache::TTL_HOUR,
+ function ( $oldValue, &$ttl, array &$setOpts ) use ( $group ) {
$dbr = wfGetDB( DB_SLAVE );
- $hit = $dbr->selectField(
+
+ $setOpts += Database::getCacheSetOptions( $dbr );
+
+ return $dbr->selectField(
'user_groups',
'COUNT(*)',
array( 'ug_group' => $group ),
__METHOD__
);
- $wgMemc->set( $key, $hit, 3600 );
- }
- self::$groupMemberCounts[$group] = $hit;
- }
- return self::$groupMemberCounts[$group];
+ },
+ array( 'pcTTL' => 10 )
+ );
}
/**