mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CiteThisPage
synced 2024-12-11 07:16:03 +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
|
@ -361,11 +361,27 @@ class Cite {
|
||||||
$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__.'-cache-get' );
|
||||||
|
$ret = $wgMemc->get( $cacheKey );
|
||||||
|
wfProfileOut( __METHOD__.'-cache' );
|
||||||
|
|
||||||
|
if ( !$ret ) {
|
||||||
wfProfileIn( __METHOD__ .'-parse' );
|
wfProfileIn( __METHOD__ .'-parse' );
|
||||||
|
|
||||||
// Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
|
// Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
|
||||||
$ret = rtrim( $this->parse( $prefix . $content . $suffix ), "\n" );
|
$ret = rtrim( $this->parse( $parserInput ), "\n" );
|
||||||
|
$wgMemc->set( $cacheKey, $ret, 86400 );
|
||||||
|
|
||||||
wfProfileOut( __METHOD__ .'-parse' );
|
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