From: Aaron Schulz Date: Thu, 5 May 2016 23:40:26 +0000 (-0700) Subject: Add TTL_PROC_* constants for clarity X-Git-Tag: 1.31.0-rc.0~7067 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=ea1f4e8a531b003e8dd5a87ec928a723ea451490;p=lhc%2Fweb%2Fwiklou.git Add TTL_PROC_* constants for clarity This makes the reason for the cache times more obvious Change-Id: Ie75df6be77c513feeb6cff3417ccbc124a6a1141 --- diff --git a/includes/SiteStats.php b/includes/SiteStats.php index 215378bcdb..6c536ddc46 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -193,7 +193,7 @@ class SiteStats { __METHOD__ ); }, - [ 'pcTTL' => 10 ] + [ 'pcTTL' => $cache::TTL_PROC_LONG ] ); } diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index 9db169755f..2d4d20f931 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -1134,7 +1134,7 @@ class ChangeTags { public static function listExtensionActivatedTags() { return ObjectCache::getMainWANInstance()->getWithSetCallback( wfMemcKey( 'active-tags' ), - 300, + WANObjectCache::TTL_MINUTE * 5, function ( $oldValue, &$ttl, array &$setOpts ) { $setOpts += Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) ); @@ -1145,8 +1145,8 @@ class ChangeTags { }, [ 'checkKeys' => [ wfMemcKey( 'active-tags' ) ], - 'lockTSE' => 300, - 'pcTTL' => 30 + 'lockTSE' => WANObjectCache::TTL_MINUTE * 5, + 'pcTTL' => WANObjectCache::TTL_PROC_LONG ] ); } @@ -1179,7 +1179,7 @@ class ChangeTags { return ObjectCache::getMainWANInstance()->getWithSetCallback( wfMemcKey( 'valid-tags-db' ), - 300, + WANObjectCache::TTL_MINUTE * 5, function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) { $dbr = wfGetDB( DB_SLAVE ); @@ -1191,8 +1191,8 @@ class ChangeTags { }, [ 'checkKeys' => [ wfMemcKey( 'valid-tags-db' ) ], - 'lockTSE' => 300, - 'pcTTL' => 30 + 'lockTSE' => WANObjectCache::TTL_MINUTE * 5, + 'pcTTL' => WANObjectCache::TTL_PROC_LONG ] ); } @@ -1209,7 +1209,7 @@ class ChangeTags { public static function listExtensionDefinedTags() { return ObjectCache::getMainWANInstance()->getWithSetCallback( wfMemcKey( 'valid-tags-hook' ), - 300, + WANObjectCache::TTL_MINUTE * 5, function ( $oldValue, &$ttl, array &$setOpts ) { $setOpts += Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) ); @@ -1219,8 +1219,8 @@ class ChangeTags { }, [ 'checkKeys' => [ wfMemcKey( 'valid-tags-hook' ) ], - 'lockTSE' => 300, - 'pcTTL' => 30 + 'lockTSE' => WANObjectCache::TTL_MINUTE * 5, + 'pcTTL' => WANObjectCache::TTL_PROC_LONG ] ); } @@ -1264,7 +1264,7 @@ class ChangeTags { $fname = __METHOD__; return ObjectCache::getMainWANInstance()->getWithSetCallback( wfMemcKey( 'change-tag-statistics' ), - 300, + WANObjectCache::TTL_MINUTE * 5, function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) { $dbr = wfGetDB( DB_SLAVE, 'vslow' ); @@ -1287,8 +1287,8 @@ class ChangeTags { }, [ 'checkKeys' => [ wfMemcKey( 'change-tag-statistics' ) ], - 'lockTSE' => 300, - 'pcTTL' => 30 + 'lockTSE' => WANObjectCache::TTL_MINUTE * 5, + 'pcTTL' => WANObjectCache::TTL_PROC_LONG ] ); } diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index 82486993ad..eaec15129c 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -227,7 +227,7 @@ class LocalRepo extends FileRepo { ? Title::makeTitle( $row->rd_namespace, $row->rd_title )->getDBkey() : ''; // negative cache }, - [ 'pcTTL' => 30 ] + [ 'pcTTL' => WANObjectCache::TTL_PROC_LONG ] ); // @note: also checks " " for b/c diff --git a/includes/jobqueue/JobQueueGroup.php b/includes/jobqueue/JobQueueGroup.php index 2dd0615a22..a4b32411cf 100644 --- a/includes/jobqueue/JobQueueGroup.php +++ b/includes/jobqueue/JobQueueGroup.php @@ -407,7 +407,7 @@ class JobQueueGroup { return [ 'v' => $wgConf->getConfig( $wiki, $name ) ]; }, - [ 'pcTTL' => 30 ] + [ 'pcTTL' => WANObjectCache::TTL_PROC_LONG ] ); return $value['v']; diff --git a/includes/libs/objectcache/IExpiringStore.php b/includes/libs/objectcache/IExpiringStore.php index fa465c7d35..91e7934a09 100644 --- a/includes/libs/objectcache/IExpiringStore.php +++ b/includes/libs/objectcache/IExpiringStore.php @@ -29,7 +29,6 @@ * @since 1.27 */ interface IExpiringStore { - // Constants for TTL values, in seconds const TTL_MINUTE = 60; const TTL_HOUR = 3600; @@ -38,5 +37,9 @@ interface IExpiringStore { const TTL_MONTH = 2592000; // 30 * 24 * 3600 const TTL_YEAR = 31536000; // 365 * 24 * 3600 + // Shorthand process cache TTLs (useful for web requests and CLI mode) + const TTL_PROC_SHORT = 3; // reasonably strict cache time that last the life of quick requests + const TTL_PROC_LONG = 30; // loose cache time that can survive slow web requests + const TTL_INDEFINITE = 0; }