Improve Cite references caching by making it dependent on a config setting, which defaults to off.

This way, we can still use it as emergency optimisation if the need arises.
This commit is contained in:
Andrew Garrett 2009-02-12 18:02:27 +00:00
parent 813c686a03
commit 43a4822175
2 changed files with 18 additions and 7 deletions

View file

@ -45,6 +45,11 @@ define( 'CITE_DEFAULT_GROUP', '');
*/
$wgAllowCiteGroups = true;
/**
* An emergency optimisation measure for caching cite <references /> output.
*/
$wgCiteCacheReferences = false;
function wfCite() {
new Cite;
return true;

View file

@ -367,18 +367,24 @@ class Cite {
$cacheKey = wfMemcKey( 'citeref', md5($parserInput), $this->mParser->Title()->getArticleID() );
wfProfileOut( __METHOD__ .'-entries' );
wfProfileIn( __METHOD__.'-cache-get' );
$data = $wgMemc->get( $cacheKey );
wfProfileOut( __METHOD__.'-cache-get' );
if ( !$data ) {
global $wgCiteCacheReferences;
if ( $wgCiteCacheReferences ) {
wfProfileIn( __METHOD__.'-cache-get' );
$data = $wgMemc->get( $cacheKey );
wfProfileOut( __METHOD__.'-cache-get' );
}
if ( empty($data) ) {
wfProfileIn( __METHOD__ .'-parse' );
// Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
$ret = rtrim( $this->parse( $parserInput ), "\n" );
$serData = $this->mParser->serialiseHalfParsedText( $ret );
$wgMemc->set( $cacheKey, $serData, 86400 );
if ( $wgCiteCacheReferences ) {
$serData = $this->mParser->serialiseHalfParsedText( $ret );
$wgMemc->set( $cacheKey, $serData, 86400 );
}
wfProfileOut( __METHOD__ .'-parse' );
} else {