* Added experimental $wgRevisionCacheExpiry to cache extracted revision text
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 18 Sep 2006 18:10:20 +0000 (18:10 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 18 Sep 2006 18:10:20 +0000 (18:10 +0000)
  in $wgMemc, to further reduce hits to external storage.
  Set to 0 (disabled) by default.

RELEASE-NOTES
includes/DefaultSettings.php
includes/Parser.php
includes/Revision.php

index b484337..2b722ac 100644 (file)
@@ -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 ==
index e035dfe..7375be9 100644 (file)
@@ -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.
index e099144..5395573 100644 (file)
@@ -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 ) {
index 8591dc1..a915a96 100644 (file)
@@ -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;