* @return String The cache key.
*/
protected function getCacheKey() {
+ wfProfileIn( __METHOD__ );
+
if ( $this->cacheKey === null ) {
$type = 'SiteList#' . SiteList::getSerialVersionId();
$source = $this->sitesTable->getName();
$this->cacheKey = wfMemcKey( "$source/$type" );
}
+ wfProfileOut( __METHOD__ );
return $this->cacheKey;
}
* @return SiteList
*/
public function getSites( $source = 'cache' ) {
+ wfProfileIn( __METHOD__ );
+
if ( $source === 'cache' ) {
if ( $this->sites === null ) {
$cache = wfGetMainCache();
$this->loadSites();
}
+ wfProfileOut( __METHOD__ );
return $this->sites;
}
* @return Site
*/
protected function siteFromRow( ORMRow $siteRow ) {
+ wfProfileIn( __METHOD__ );
+
$site = Site::newForType( $siteRow->getField( 'type', Site::TYPE_UNKNOWN ) );
$site->setGlobalId( $siteRow->getField( 'global_key' ) );
$site->setExtraConfig( $siteRow->getField( 'config' ) );
}
+ wfProfileOut( __METHOD__ );
return $site;
}
* @since 1.21
*/
protected function loadSites() {
+ wfProfileIn( __METHOD__ );
+
$this->sites = new SiteList();
foreach ( $this->sitesTable->select() as $siteRow ) {
$cache = wfGetMainCache();
$cache->set( $this->getCacheKey(), $this->sites );
+
+ wfProfileOut( __METHOD__ );
}
/**
* @return Site|null
*/
public function getSite( $globalId, $source = 'cache' ) {
+ wfProfileIn( __METHOD__ );
+
$sites = $this->getSites( $source );
+ wfProfileOut( __METHOD__ );
return $sites->hasSite( $globalId ) ? $sites->getSite( $globalId ) : null;
}
* @return boolean Success indicator
*/
public function saveSites( array $sites ) {
+ wfProfileIn( __METHOD__ );
+
if ( empty( $sites ) ) {
+ wfProfileOut( __METHOD__ );
return true;
}
// purge cache
$this->reset();
+ wfProfileOut( __METHOD__ );
return $success;
}
* @since 1.21
*/
public function reset() {
+ wfProfileIn( __METHOD__ );
// purge cache
$cache = wfGetMainCache();
$cache->delete( $this->getCacheKey() );
$this->sites = null;
+
+ wfProfileOut( __METHOD__ );
}
/**
* @return bool success
*/
public function clear() {
+ wfProfileIn( __METHOD__ );
$dbw = $this->sitesTable->getWriteDbConnection();
$trx = $dbw->trxLevel();
$this->reset();
+ wfProfileOut( __METHOD__ );
return $ok;
}