X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FBlockCache.php;h=c64adc1094d9a03636cb33db4685d120ef2ceedf;hb=97bfb998ee07677a208b0578a7cc67d6e2936849;hp=8f9a5a60aa10cd61759b45ab7d931ecbd1175bab;hpb=7e901668b2a30b9003b924bd80d0b7e2117e90b4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/BlockCache.php b/includes/BlockCache.php index 8f9a5a60aa..c64adc1094 100644 --- a/includes/BlockCache.php +++ b/includes/BlockCache.php @@ -2,6 +2,7 @@ /** * Contain the blockcache class * @package MediaWiki + * @package Cache */ /** @@ -36,15 +37,16 @@ class BlockCache /** * Load the blocks from the database and save them to memcached + * @param bool $bFromSlave Whether to load data from slaves or master */ - function loadFromDB() { + function loadFromDB( $bFromSlave = false ) { global $wgUseMemCached, $wgMemc; $this->mData = array(); # Selecting FOR UPDATE is a convenient way to serialise the memcached and DB operations, # which is necessary even though we don't update the DB - if ( $wgUseMemCached ) { + if ( !$bFromSlave ) { Block::enumBlocks( 'wfBlockCacheInsert', '', EB_FOR_UPDATE ); - $wgMemc->set( $this->mMemcKey, $this->mData, 0 ); + #$wgMemc->set( $this->mMemcKey, $this->mData, 0 ); } else { Block::enumBlocks( 'wfBlockCacheInsert', '' ); } @@ -53,18 +55,21 @@ class BlockCache /** * Load the cache from memcached or, if that's not possible, from the DB */ - function load() { + function load( $bFromSlave ) { global $wgUseMemCached, $wgMemc; if ( $this->mData === false) { + $this->loadFromDB( $bFromSlave ); +/* + // Memcache disabled for performance issues. # Try memcached if ( $wgUseMemCached ) { $this->mData = $wgMemc->get( $this->mMemcKey ); } if ( !is_array( $this->mData ) ) { - $this->loadFromDB(); - } + $this->loadFromDB( $bFromSlave ); + }*/ } } @@ -91,9 +96,10 @@ class BlockCache * Find out if a given IP address is blocked * * @param String $ip IP address + * @param bool $bFromSlave True means to load check against slave, else check against master. */ - function get( $ip ) { - $this->load(); + function get( $ip, $bFromSlave ) { + $this->load( $bFromSlave ); $ipint = ip2long( $ip ); $blocked = false; @@ -110,6 +116,7 @@ class BlockCache $ip = Block::normaliseRange( $ip ); } $block = new Block(); + $block->forUpdate( $bFromSlave ); $block->load( $ip ); } else { $block = false;