r101484 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101483‎ | r101484 | r101485 >
Date:15:39, 1 November 2011
Author:catrope
Status:ok
Tags:
Comment:
[RL2] Fix stupid typos in r101469. Also have maybeLoadIDs() cache the individual gadgets' data in memc for efficiency
Modified paths:
  • /branches/RL2/extensions/Gadgets/backend/CachedGadgetRepo.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/backend/ForeignDBGadgetRepo.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/backend/ForeignDBGadgetRepo.php
@@ -90,7 +90,7 @@
9191 }
9292
9393 protected function getLoadAllDataQuery() {
94 - $query = parent::getLoadIDsQuery();
 94+ $query = parent::getLoadAllDataQuery();
9595 $query['conds']['gd_shared'] = 1;
9696 return $query;
9797 }
Index: branches/RL2/extensions/Gadgets/backend/CachedGadgetRepo.php
@@ -121,12 +121,18 @@
122122 }
123123
124124 $this->data = $this->loadAllData();
 125+ $arrayKeys = array_keys( $this->data );
125126 // For memc, prepare an array with the IDs as keys but with each value set to null
126 - $toCache = array_combine( array_keys( $data ), array_fill( 0, count( $this->data ), null ) );
 127+ $toCache = array_combine( $arrayKeys, array_fill( 0, count( $arrayKeys ), null ) );
 128+ $wgMemc->set( $key, $toCache );
127129
128 - $wgMemc->set( $key, $toCache );
 130+ // Now that we have the data for every gadget, let's refresh those cache entries too
 131+ foreach ( $this->data as $id => $gadgetData ) {
 132+ $wgMemc->set( $this->getCacheKey( $id ), $gadgetData );
 133+ }
 134+
129135 $this->idsLoaded = true;
130 - return array_keys( $this->data );
 136+ return $arrayKeys;
131137 }
132138
133139 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101469[RL2] Factor the caching logic out of LocalGadgetRepo into CachedGadgetRepo, ...catrope13:13, 1 November 2011

Status & tagging log