Index: branches/wmf/1.17wmf1/includes/objectcache/SqlBagOStuff.php |
— | — | @@ -8,17 +8,28 @@ |
9 | 9 | class SqlBagOStuff extends BagOStuff { |
10 | 10 | var $lb, $db, $serverInfo; |
11 | 11 | var $lastExpireAll = 0; |
| 12 | + var $purgePeriod = 100; |
12 | 13 | |
13 | 14 | /** |
14 | 15 | * Constructor. Parameters are: |
15 | 16 | * - server: A server info structure in the format required by each |
16 | 17 | * element in $wgDBServers. |
| 18 | + * |
| 19 | + * - purgePeriod: The average number of object cache requests in between |
| 20 | + * garbage collection operations, where expired entries |
| 21 | + * are removed from the database. Or in other words, the |
| 22 | + * reciprocal of the probability of purging on any given |
| 23 | + * request. If this is set to zero, purging will never be |
| 24 | + * done. |
17 | 25 | */ |
18 | 26 | public function __construct( $params ) { |
19 | 27 | if ( isset( $params['server'] ) ) { |
20 | 28 | $this->serverInfo = $params['server']; |
21 | 29 | $this->serverInfo['load'] = 1; |
22 | 30 | } |
| 31 | + if ( isset( $params['purgePeriod'] ) ) { |
| 32 | + $this->purgePeriod = intval( $params['purgePeriod'] ); |
| 33 | + } |
23 | 34 | } |
24 | 35 | |
25 | 36 | protected function getDB() { |
— | — | @@ -200,15 +211,20 @@ |
201 | 212 | } |
202 | 213 | |
203 | 214 | protected function garbageCollect() { |
204 | | - /* Ignore 99% of requests */ |
205 | | - if ( !mt_rand( 0, 100 ) ) { |
206 | | - $now = time(); |
207 | | - /* Avoid repeating the delete within a few seconds */ |
208 | | - if ( $now > ( $this->lastExpireAll + 1 ) ) { |
209 | | - $this->lastExpireAll = $now; |
210 | | - $this->expireAll(); |
211 | | - } |
| 215 | + if ( !$this->purgePeriod ) { |
| 216 | + // Disabled |
| 217 | + return; |
212 | 218 | } |
| 219 | + // Only purge on one in every $this->purgePeriod requests. |
| 220 | + if ( $this->purgePeriod !== 1 && mt_rand( 0, $this->purgePeriod - 1 ) ) { |
| 221 | + return; |
| 222 | + } |
| 223 | + $now = time(); |
| 224 | + // Avoid repeating the delete within a few seconds |
| 225 | + if ( $now > ( $this->lastExpireAll + 1 ) ) { |
| 226 | + $this->lastExpireAll = $now; |
| 227 | + $this->expireAll(); |
| 228 | + } |
213 | 229 | } |
214 | 230 | |
215 | 231 | public function expireAll() { |
Property changes on: branches/wmf/1.17wmf1/includes/objectcache/SqlBagOStuff.php |
___________________________________________________________________ |
Added: svn:mergeinfo |
216 | 232 | Merged /branches/new-installer/phase3/includes/objectcache/SqlBagOStuff.php:r43664-66004 |
217 | 233 | Merged /branches/wmf-deployment/includes/objectcache/SqlBagOStuff.php:r53381,60970 |
218 | 234 | Merged /branches/REL1_15/phase3/includes/objectcache/SqlBagOStuff.php:r51646 |
219 | 235 | Merged /branches/wmf/1.16wmf4/includes/objectcache/SqlBagOStuff.php:r67177,69199,76243,77266 |
220 | 236 | Merged /branches/sqlite/includes/objectcache/SqlBagOStuff.php:r58211-58321 |
221 | 237 | Merged /trunk/phase3/includes/objectcache/SqlBagOStuff.php:r83590,85862,89512-89513 |