return is_object( $value ) ? $value : false;
}
+ /**
+ * @param WikiPage $article
+ * @param string $metricSuffix
+ */
+ private function incrementStats( $article, $metricSuffix ) {
+ // old style global metric (can be removed once no longer used)
+ wfIncrStats( 'pcache.' . $metricSuffix );
+ // new per content model metric
+ $contentModel = str_replace( '.', '_', $article->getContentModel() );
+ $metricSuffix = str_replace( '.', '_', $metricSuffix );
+ wfIncrStats( 'pcache.' . $contentModel . '.' . $metricSuffix );
+ }
+
/**
* Generates a key for caching the given article considering
* the given parser options.
$this->getOptionsKey( $article ), $casToken, BagOStuff::READ_VERIFIED );
if ( $optionsKey instanceof CacheTime ) {
if ( $useOutdated < self::USE_EXPIRED && $optionsKey->expired( $article->getTouched() ) ) {
- wfIncrStats( "pcache.miss.expired" );
+ $this->incrementStats( $article, "miss.expired" );
$cacheTime = $optionsKey->getCacheTime();
wfDebugLog( "ParserCache",
"Parser options key expired, touched " . $article->getTouched()
} elseif ( $useOutdated < self::USE_OUTDATED &&
$optionsKey->isDifferentRevision( $article->getLatest() )
) {
- wfIncrStats( "pcache.miss.revid" );
+ $this->incrementStats( $article, "miss.revid" );
$revId = $article->getLatest();
$cachedRevId = $optionsKey->getCacheRevisionId();
wfDebugLog( "ParserCache",
$useOutdated ? self::USE_OUTDATED : self::USE_CURRENT_ONLY
);
if ( $parserOutputKey === false ) {
- wfIncrStats( 'pcache.miss.absent' );
+ $this->incrementStats( $article, 'miss.absent' );
return false;
}
$value = $this->mMemc->get( $parserOutputKey, $casToken, BagOStuff::READ_VERIFIED );
if ( !$value ) {
wfDebug( "ParserOutput cache miss.\n" );
- wfIncrStats( "pcache.miss.absent" );
+ $this->incrementStats( $article, "miss.absent" );
return false;
}
: $article;
if ( !$useOutdated && $value->expired( $touched ) ) {
- wfIncrStats( "pcache.miss.expired" );
+ $this->incrementStats( $article, "miss.expired" );
$cacheTime = $value->getCacheTime();
wfDebugLog( "ParserCache",
"ParserOutput key expired, touched $touched, "
. "epoch {$this->cacheEpoch}, cached $cacheTime\n" );
$value = false;
} elseif ( !$useOutdated && $value->isDifferentRevision( $article->getLatest() ) ) {
- wfIncrStats( "pcache.miss.revid" );
+ $this->incrementStats( $article, "miss.revid" );
$revId = $article->getLatest();
$cachedRevId = $value->getCacheRevisionId();
wfDebugLog( "ParserCache",
} elseif (
Hooks::run( 'RejectParserCacheValue', [ $value, $wikiPage, $popts ] ) === false
) {
- wfIncrStats( 'pcache.miss.rejected' );
+ $this->incrementStats( $article, 'miss.rejected' );
wfDebugLog( "ParserCache",
"ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n"
);
$value = false;
} else {
- wfIncrStats( "pcache.hit" );
+ $this->incrementStats( $article, "hit" );
}
return $value;