diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2010-07-28 11:52:48 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2010-07-28 11:52:48 +0200 |
commit | 222b01f5169f1c7e69762e0e8904c24f78f71882 (patch) | |
tree | 8e932e12546bb991357ec48eb1638d1770be7a35 /includes/parser/ParserCache.php | |
parent | 00ab76a6b686e98a914afc1975812d2b1aaa7016 (diff) |
update to MediaWiki 1.16.0
Diffstat (limited to 'includes/parser/ParserCache.php')
-rw-r--r-- | includes/parser/ParserCache.php | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index d17214c3..524d6be5 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -7,7 +7,7 @@ class ParserCache { /** * Get an instance of this object */ - public static function &singleton() { + public static function singleton() { static $instance; if ( !isset( $instance ) ) { global $parserMemc; @@ -22,11 +22,11 @@ class ParserCache { * * @param object $memCached */ - function __construct( &$memCached ) { - $this->mMemc =& $memCached; + function __construct( $memCached ) { + $this->mMemc = $memCached; } - function getKey( &$article, $popts ) { + function getKey( $article, $popts ) { global $wgRequest; if( $popts instanceof User ) // It used to be getKey( &$article, &$user ) @@ -47,52 +47,55 @@ class ParserCache { return $key; } - function getETag( &$article, $popts ) { + function getETag( $article, $popts ) { return 'W/"' . $this->getKey($article, $popts) . "--" . $article->mTouched. '"'; } - function get( &$article, $popts ) { - global $wgCacheEpoch; - $fname = 'ParserCache::get'; - wfProfileIn( $fname ); - + function getDirty( $article, $popts ) { $key = $this->getKey( $article, $popts ); - wfDebug( "Trying parser cache $key\n" ); $value = $this->mMemc->get( $key ); - if ( is_object( $value ) ) { - wfDebug( "Found.\n" ); - # Delete if article has changed since the cache was made - $canCache = $article->checkTouched(); - $cacheTime = $value->getCacheTime(); - $touched = $article->mTouched; - if ( !$canCache || $value->expired( $touched ) ) { - if ( !$canCache ) { - wfIncrStats( "pcache_miss_invalid" ); - wfDebug( "Invalid cached redirect, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" ); - } else { - wfIncrStats( "pcache_miss_expired" ); - wfDebug( "Key expired, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" ); - } - $this->mMemc->delete( $key ); - $value = false; - } else { - if ( isset( $value->mTimestamp ) ) { - $article->mTimestamp = $value->mTimestamp; - } - wfIncrStats( "pcache_hit" ); - } - } else { + return is_object( $value ) ? $value : false; + } + + function get( $article, $popts ) { + global $wgCacheEpoch; + wfProfileIn( __METHOD__ ); + + $value = $this->getDirty( $article, $popts ); + if ( !$value ) { wfDebug( "Parser cache miss.\n" ); wfIncrStats( "pcache_miss_absent" ); + wfProfileOut( __METHOD__ ); + return false; + } + + wfDebug( "Found.\n" ); + # Invalid if article has changed since the cache was made + $canCache = $article->checkTouched(); + $cacheTime = $value->getCacheTime(); + $touched = $article->mTouched; + if ( !$canCache || $value->expired( $touched ) ) { + if ( !$canCache ) { + wfIncrStats( "pcache_miss_invalid" ); + wfDebug( "Invalid cached redirect, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" ); + } else { + wfIncrStats( "pcache_miss_expired" ); + wfDebug( "Key expired, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" ); + } $value = false; + } else { + if ( isset( $value->mTimestamp ) ) { + $article->mTimestamp = $value->mTimestamp; + } + wfIncrStats( "pcache_hit" ); } - wfProfileOut( $fname ); + wfProfileOut( __METHOD__ ); return $value; } - function save( $parserOutput, &$article, $popts ){ + function save( $parserOutput, $article, $popts ){ global $wgParserCacheExpireTime; $key = $this->getKey( $article, $popts ); |