From 37b08163ea592c58b267476b41edb84e312ff5bb Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 7 Sep 2016 14:19:31 -0700 Subject: [PATCH] Make $wgRevisionCacheExpiry default to one week * If CACHE_DB is used, it will not use the cache however. * If persistent cache is disabled, at least maintain the process caching. Change-Id: I23b455ef46f27c313bb9573f69723b1436b2d584 --- RELEASE-NOTES-1.28 | 1 + includes/DefaultSettings.php | 2 +- includes/Revision.php | 15 ++++++++------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES-1.28 b/RELEASE-NOTES-1.28 index 9843d90019..bd05309d6c 100644 --- a/RELEASE-NOTES-1.28 +++ b/RELEASE-NOTES-1.28 @@ -32,6 +32,7 @@ production. * The 'editcontentmodel' permission is now granted to all logged-in users ('user'). instead of just administrators ('sysop'). Documentation for this feature is available at . +* $wgRevisionCacheExpiry is now set to one week by default instead of being disabled. === New features in 1.28 === * User::isBot() method for checking if an account is a bot role account. diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 3bf838121e..03947f6a07 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2123,7 +2123,7 @@ $wgDefaultExternalStore = false; * * Set to 0 to disable, or number of seconds before cache expiry. */ -$wgRevisionCacheExpiry = 0; +$wgRevisionCacheExpiry = 86400 * 7; /** @} */ # end text storage } diff --git a/includes/Revision.php b/includes/Revision.php index ef0f03df8f..af45acc290 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -1577,19 +1577,20 @@ class Revision implements IDBAccessObject { * @return string|bool The revision's text, or false on failure */ private function loadText() { - // Caching may be beneficial for massive use of external storage global $wgRevisionCacheExpiry; - if ( !$wgRevisionCacheExpiry ) { - return $this->fetchText(); - } - $cache = ObjectCache::getMainWANInstance(); + if ( $cache->getQoS( $cache::ATTR_EMULATION ) <= $cache::QOS_EMULATION_SQL ) { + // Do not cache RDBMs blobs in...the RDBMs store + $ttl = $cache::TTL_UNCACHEABLE; + } else { + $ttl = $wgRevisionCacheExpiry ?: $cache::TTL_UNCACHEABLE; + } // No negative caching; negative hits on text rows may be due to corrupted replica DBs return $cache->getWithSetCallback( - $key = $cache->makeKey( 'revisiontext', 'textid', $this->getTextId() ), - $wgRevisionCacheExpiry, + $cache->makeKey( 'revisiontext', 'textid', $this->getTextId() ), + $ttl, function () { return $this->fetchText(); }, -- 2.20.1