From 376014e981da83017a7759d4230a00e4b9f0f8b8 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 18 Sep 2006 18:10:20 +0000 Subject: [PATCH] * Added experimental $wgRevisionCacheExpiry to cache extracted revision text in $wgMemc, to further reduce hits to external storage. Set to 0 (disabled) by default. --- RELEASE-NOTES | 3 +++ includes/DefaultSettings.php | 8 ++++++++ includes/Parser.php | 2 +- includes/Revision.php | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b484337e96..2b722acf17 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -210,6 +210,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN for page titles which shouldn't be converted on display/linking * Lazy extraction of text chunks in Revision objects, may reduce hits to external storage when actual text content is not used +* Added experimental $wgRevisionCacheExpiry to cache extracted revision text + in $wgMemc, to further reduce hits to external storage. + Set to 0 (disabled) by default. == Languages updated == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index e035dfe5f9..7375be9443 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2070,6 +2070,14 @@ $wgExternalServers = array(); */ $wgDefaultExternalStore = false; +/** + * Revision text may be cached in $wgMemc to reduce load on external storage + * servers and object extraction overhead for frequently-loaded revisions. + * + * Set to 0 to disable, or number of seconds before cache expiry. + */ +$wgRevisionCacheExpiry = 0; + /** * list of trusted media-types and mime types. * Use the MEDIATYPE_xxx constants to represent media types. diff --git a/includes/Parser.php b/includes/Parser.php index e099144154..539557398c 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2716,7 +2716,7 @@ class Parser if ( !$argsOnly ) { $braceCallbacks[2] = array( &$this, 'braceSubstitution' ); } - if ( !$this->mOutputType != OT_MSG ) { + if ( $this->mOutputType != OT_MSG ) { $braceCallbacks[3] = array( &$this, 'argSubstitution' ); } if ( $braceCallbacks ) { diff --git a/includes/Revision.php b/includes/Revision.php index 8591dc13c1..a915a96019 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -672,6 +672,17 @@ class Revision { $fname = 'Revision::loadText'; wfProfileIn( $fname ); + // Caching may be beneficial for massive use of external storage + global $wgRevisionCacheExpiry, $wgMemc, $wgDBname; + $key = "$wgDBname:revisiontext:textid:" . $this->getTextId(); + if( $wgRevisionCacheExpiry ) { + $text = $wgMemc->get( $key ); + if( is_string( $text ) ) { + wfProfileOut( $fname ); + return $text; + } + } + // If we kept data for lazy extraction, use it now... $row = $this->mTextRow; $this->mTextRow = null; @@ -695,6 +706,11 @@ class Revision { } $text = Revision::getRevisionText( $row ); + + if( $wgRevisionCacheExpiry ) { + $wgMemc->set( $key, $text, $wgRevisionCacheExpiry ); + } + wfProfileOut( $fname ); return $text; -- 2.20.1