From 9daededf7f625af249cf81d05a430e3727003775 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Tue, 4 Jan 2005 12:54:07 +0000 Subject: [PATCH] stats merged from REL1_3A --- includes/ParserCache.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/includes/ParserCache.php b/includes/ParserCache.php index 00ed003058..4447869b31 100644 --- a/includes/ParserCache.php +++ b/includes/ParserCache.php @@ -35,6 +35,7 @@ class ParserCache { $hash = $user->getPageRenderingHash(); $pageid = intval( $article->getID() ); $key = $this->getKey( $article, $user ); + wfDebug( "Trying parser cache $key\n" ); $value = $this->mMemc->get( $key ); if ( is_object( $value ) ) { @@ -45,15 +46,21 @@ class ParserCache { $touched = $article->mTouched; if ( !$canCache || $value->expired( $touched ) ) { if ( !$canCache ) { + $this->incrStats( "pcache_miss_invalid" ); wfDebug( "Invalid cached redirect, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" ); } else { + $this->incrStats( "pcache_miss_expired" ); wfDebug( "Key expired, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" ); } $this->mMemc->delete( $key ); $value = false; + + } else { + $this->incrStats( "pcache_hit" ); } } else { wfDebug( "Parser cache miss.\n" ); + $this->incrStats( "pcache_miss_absent" ); $value = false; } @@ -75,6 +82,14 @@ class ParserCache { } $this->mMemc->set( $key, $parserOutput, $expire ); } + + function incrStats( $key ) { + global $wgDBname, $wgMemc; + $key = "$wgDBname:stats:$key"; + if ( is_null( $wgMemc->incr( $key ) ) ) { + $wgMemc->add( $key, 1 ); + } + } } -- 2.20.1