http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90942
Revision: 90942
Author: tstarling
Date: 2011-06-28 06:30:16 +0000 (Tue, 28 Jun 2011)
Log Message:
-----------
MFT r85862: configurable purging for MySQL cache
Modified Paths:
--------------
branches/wmf/1.17wmf1/includes/objectcache/SqlBagOStuff.php
Property Changed:
----------------
branches/wmf/1.17wmf1/includes/objectcache/SqlBagOStuff.php
Modified: branches/wmf/1.17wmf1/includes/objectcache/SqlBagOStuff.php
===================================================================
--- branches/wmf/1.17wmf1/includes/objectcache/SqlBagOStuff.php 2011-06-28
05:57:55 UTC (rev 90941)
+++ branches/wmf/1.17wmf1/includes/objectcache/SqlBagOStuff.php 2011-06-28
06:30:16 UTC (rev 90942)
@@ -8,17 +8,28 @@
class SqlBagOStuff extends BagOStuff {
var $lb, $db, $serverInfo;
var $lastExpireAll = 0;
+ var $purgePeriod = 100;
/**
* Constructor. Parameters are:
* - server: A server info structure in the format required by each
* element in $wgDBServers.
+ *
+ * - purgePeriod: The average number of object cache requests in
between
+ * garbage collection operations, where expired
entries
+ * are removed from the database. Or in other words,
the
+ * reciprocal of the probability of purging on any
given
+ * request. If this is set to zero, purging will never
be
+ * done.
*/
public function __construct( $params ) {
if ( isset( $params['server'] ) ) {
$this->serverInfo = $params['server'];
$this->serverInfo['load'] = 1;
}
+ if ( isset( $params['purgePeriod'] ) ) {
+ $this->purgePeriod = intval( $params['purgePeriod'] );
+ }
}
protected function getDB() {
@@ -200,15 +211,20 @@
}
protected function garbageCollect() {
- /* Ignore 99% of requests */
- if ( !mt_rand( 0, 100 ) ) {
- $now = time();
- /* Avoid repeating the delete within a few seconds */
- if ( $now > ( $this->lastExpireAll + 1 ) ) {
- $this->lastExpireAll = $now;
- $this->expireAll();
- }
+ if ( !$this->purgePeriod ) {
+ // Disabled
+ return;
}
+ // Only purge on one in every $this->purgePeriod requests.
+ if ( $this->purgePeriod !== 1 && mt_rand( 0, $this->purgePeriod
- 1 ) ) {
+ return;
+ }
+ $now = time();
+ // Avoid repeating the delete within a few seconds
+ if ( $now > ( $this->lastExpireAll + 1 ) ) {
+ $this->lastExpireAll = $now;
+ $this->expireAll();
+ }
}
public function expireAll() {
Property changes on: branches/wmf/1.17wmf1/includes/objectcache/SqlBagOStuff.php
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/REL1_15/phase3/includes/objectcache/SqlBagOStuff.php:51646
/branches/new-installer/phase3/includes/objectcache/SqlBagOStuff.php:43664-66004
/branches/sqlite/includes/objectcache/SqlBagOStuff.php:58211-58321
/branches/wmf/1.16wmf4/includes/objectcache/SqlBagOStuff.php:67177,69199,76243,77266
/branches/wmf-deployment/includes/objectcache/SqlBagOStuff.php:53381,60970
/trunk/phase3/includes/objectcache/SqlBagOStuff.php:83590,85862,89512-89513
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs