mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 06:54:00 +00:00
Cache cite <references /> output by contents. That way, changes that don't affect Cite references won't cause a re-parsing of Cite, which is a big CPU hog on Wikimedia.
This commit is contained in:
parent
439ba88a51
commit
d35dbd9f50
|
@ -360,12 +360,28 @@ class Cite {
|
||||||
$prefix = wfMsgForContentNoTrans( 'cite_references_prefix' );
|
$prefix = wfMsgForContentNoTrans( 'cite_references_prefix' );
|
||||||
$suffix = wfMsgForContentNoTrans( 'cite_references_suffix' );
|
$suffix = wfMsgForContentNoTrans( 'cite_references_suffix' );
|
||||||
$content = implode( "\n", $ent );
|
$content = implode( "\n", $ent );
|
||||||
|
|
||||||
|
// Let's try to cache it.
|
||||||
|
$parserInput = $prefix . $content . $suffix;
|
||||||
|
global $wgMemc;
|
||||||
|
$cacheKey = wfMemcKey( 'citeref', md5($parserInput), $this->mParser->Title()->getArticleID() );
|
||||||
|
|
||||||
wfProfileOut( __METHOD__ .'-entries' );
|
wfProfileOut( __METHOD__ .'-entries' );
|
||||||
wfProfileIn( __METHOD__ .'-parse' );
|
|
||||||
// Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
|
wfProfileIn( __METHOD__.'-cache-get' );
|
||||||
$ret = rtrim( $this->parse( $prefix . $content . $suffix ), "\n" );
|
$ret = $wgMemc->get( $cacheKey );
|
||||||
wfProfileOut( __METHOD__ .'-parse' );
|
wfProfileOut( __METHOD__.'-cache' );
|
||||||
|
|
||||||
|
if ( !$ret ) {
|
||||||
|
wfProfileIn( __METHOD__ .'-parse' );
|
||||||
|
|
||||||
|
// Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
|
||||||
|
$ret = rtrim( $this->parse( $parserInput ), "\n" );
|
||||||
|
$wgMemc->set( $cacheKey, $ret, 86400 );
|
||||||
|
|
||||||
|
wfProfileOut( __METHOD__ .'-parse' );
|
||||||
|
}
|
||||||
|
|
||||||
wfProfileOut( __METHOD__ );
|
wfProfileOut( __METHOD__ );
|
||||||
|
|
||||||
//done, clean up so we can reuse the group
|
//done, clean up so we can reuse the group
|
||||||
|
|
Loading…
Reference in a new issue