New updateSpecialPages.php script, to update the QueryPage cache. Disabled recache...
[lhc/web/wiklou.git] / includes / BlockCache.php
index 8f9a5a6..c64adc1 100644 (file)
@@ -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;