r44804 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44803‎ | r44804 | r44805 >
Date:14:51, 19 December 2008
Author:aaron
Status:reverted (Comments)
Tags:
Comment:
Store negative results in cache
Modified paths:
  • /trunk/phase3/includes/Interwiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Interwiki.php
@@ -143,24 +143,27 @@
144144 $key = wfMemcKey( 'interwiki', $prefix );
145145 $mc = $wgMemc->get( $key );
146146 $iw = false;
147 - if( $mc && is_array( $mc ) ){ // is_array is hack for old keys
 147+ if( $mc && is_array( $mc ) ) { // is_array is hack for old keys
148148 $iw = Interwiki::loadFromArray( $mc );
149149 if( $iw ){
150150 return $iw;
151151 }
 152+ } else if( $mc === 0 ) {
 153+ return false; // negative result cached
152154 }
153 -
154155 $db = wfGetDB( DB_SLAVE );
155 -
156156 $row = $db->fetchRow( $db->select( 'interwiki', '*', array( 'iw_prefix' => $prefix ),
157157 __METHOD__ ) );
158158 $iw = Interwiki::loadFromArray( $row );
159 - if ( $iw ) {
 159+ if( $iw ) {
160160 $mc = array( 'iw_url' => $iw->mURL, 'iw_local' => $iw->mLocal, 'iw_trans' => $iw->mTrans );
161161 $wgMemc->add( $key, $mc );
162162 return $iw;
 163+ } else {
 164+ # Pages like "Command & Conquer 3: Kane's Wrath" may keep checking
 165+ # the prefix. Cache the negative result to avoid extra db hits.
 166+ $wgMemc->add( $key, 0 );
163167 }
164 -
165168 return false;
166169 }
167170

Follow-up revisions

RevisionCommit summaryAuthorDate
r44964Revert r44804 "Store negative [interwiki] results in cache"...brion19:45, 23 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   19:46, 23 December 2008

Reverted for now in r44964.

Caching negative results for a long period would be extremely annoying when adding a new prefix and discovering it doesn't work. Negative cache needs to either be much, much shorter or have a clear easy way to purge it.

Status & tagging log