Index: branches/RL2/extensions/Gadgets/backend/LocalGadgetRepo.php |
— | — | @@ -8,6 +8,9 @@ |
9 | 9 | protected $data = array(); |
10 | 10 | protected $namesLoaded = false; |
11 | 11 | |
| 12 | + /** Memcached key of the gadget names list. Subclasses may override this in their constructor */ |
| 13 | + protected $namesKey; |
| 14 | + |
12 | 15 | /*** Public methods inherited from GadgetRepo ***/ |
13 | 16 | |
14 | 17 | /** |
— | — | @@ -19,6 +22,8 @@ |
20 | 23 | |
21 | 24 | // TODO: define options |
22 | 25 | // FIXME if there are none, drop the mandatory param |
| 26 | + |
| 27 | + $this->namesKey = $this->getMemcKey( 'gadgets', 'localreponames' ); |
23 | 28 | } |
24 | 29 | |
25 | 30 | public function getGadgetIds() { |
— | — | @@ -99,9 +104,8 @@ |
100 | 105 | $wgMemc->set( $key, $this->data[$id] ); |
101 | 106 | } |
102 | 107 | // Clear the gadget names array in memc |
103 | | - $namesKey = $this->getMemcKey( 'gadgets', 'localreponames' ); |
104 | | - if ( $namesKey !== false ) { |
105 | | - $wgMemc->delete( $namesKey ); |
| 108 | + if ( $this->namesKey !== false ) { |
| 109 | + $wgMemc->delete( $this->namesKey ); |
106 | 110 | } |
107 | 111 | |
108 | 112 | return Status::newGood(); |
— | — | @@ -126,9 +130,8 @@ |
127 | 131 | $wgMemc->delete( $key ); |
128 | 132 | } |
129 | 133 | // Clear the gadget names array in memc |
130 | | - $namesKey = $this->getMemcKey( 'gadgets', 'localreponames' ); |
131 | | - if ( $namesKey !== false ) { |
132 | | - $wgMemc->delete( $namesKey ); |
| 134 | + if ( $this->namesKey !== false ) { |
| 135 | + $wgMemc->delete( $this->namesKey ); |
133 | 136 | } |
134 | 137 | |
135 | 138 | if ( $affectedRows === 0 ) { |
— | — | @@ -180,8 +183,7 @@ |
181 | 184 | } |
182 | 185 | |
183 | 186 | // Try memc |
184 | | - $key = $this->getMemcKey( 'gadgets', 'localreponames' ); |
185 | | - $cached = $key !== false ? $wgMemc->get( $key ) : false; |
| 187 | + $cached = $this->namesKey !== false ? $wgMemc->get( $this->namesKey ) : false; |
186 | 188 | if ( is_array( $cached ) ) { |
187 | 189 | // Yay, data is in cache |
188 | 190 | // Add to $this->data , but let things already in $this->data take precedence |
Index: branches/RL2/extensions/Gadgets/backend/ForeignDBGadgetRepo.php |
— | — | @@ -25,6 +25,8 @@ |
26 | 26 | public function __construct( array $options ) { |
27 | 27 | parent::__construct( $options ); |
28 | 28 | |
| 29 | + $this->namesKey = $this->getMemcKey( 'gadgets', 'foreigndbreponames' ); |
| 30 | + |
29 | 31 | $optionKeys = array( 'source', 'dbType', 'dbServer', 'dbUser', 'dbPassword', 'dbName', |
30 | 32 | 'dbFlags', 'tablePrefix', 'hasSharedCache' ); |
31 | 33 | foreach ( $optionKeys as $optionKey ) { |
— | — | @@ -64,11 +66,6 @@ |
65 | 67 | protected function getMemcKey( /* ... */ ) { |
66 | 68 | if ( $this->hasSharedCache ) { |
67 | 69 | $args = func_get_args(); |
68 | | - // FIXME: This is a dirty hack. Need to cache localrepo and foreignrepo name lists separately |
69 | | - // because one includes non-shared gadgets and the other doesn't |
70 | | - if ( $args[1] === 'localreponames' ) { |
71 | | - $args[1] = 'foreignreponames'; |
72 | | - } |
73 | 70 | array_unshift( $args, $this->dbName, $this->tablePrefix ); |
74 | 71 | return call_user_func_array( 'wfForeignMemcKey', $args ); |
75 | 72 | } else { |