From: Aaron Schulz Date: Tue, 18 Jun 2019 15:35:27 +0000 (+0100) Subject: parsercache: use WRITE_ALLOW_SEGMENTS for cached ParserOutput values X-Git-Tag: 1.34.0-rc.0~594^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=6c31ca3f257243daeb0b4cde3f110d2879cecde8;p=lhc%2Fweb%2Fwiklou.git parsercache: use WRITE_ALLOW_SEGMENTS for cached ParserOutput values This lets large output entries fit into memcached via key segmentation. Follows b09b3980f99 which applied the feature to PageEditStash. Bug: T204742 Change-Id: I33a60f5d718cd9033ea12d1d16046d2bede87b5b --- diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index 2585872c2f..f87135892f 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -49,7 +49,7 @@ class ParserCache { const USE_ANYTHING = 3; /** @var BagOStuff */ - private $mMemc; + private $cache; /** * Anything cached prior to this is invalidated @@ -79,7 +79,7 @@ class ParserCache { * @throws MWException */ public function __construct( BagOStuff $cache, $cacheEpoch = '20030516000000' ) { - $this->mMemc = $cache; + $this->cache = $cache; $this->cacheEpoch = $cacheEpoch; } @@ -95,7 +95,7 @@ class ParserCache { $pageid = $article->getId(); $renderkey = (int)( $wgRequest->getVal( 'action' ) == 'render' ); - $key = $this->mMemc->makeKey( 'pcache', 'idhash', "{$pageid}-{$renderkey}!{$hash}" ); + $key = $this->cache->makeKey( 'pcache', 'idhash', "{$pageid}-{$renderkey}!{$hash}" ); return $key; } @@ -104,7 +104,7 @@ class ParserCache { * @return mixed|string */ protected function getOptionsKey( $page ) { - return $this->mMemc->makeKey( 'pcache', 'idoptions', $page->getId() ); + return $this->cache->makeKey( 'pcache', 'idoptions', $page->getId() ); } /** @@ -112,7 +112,7 @@ class ParserCache { * @since 1.28 */ public function deleteOptionsKey( $page ) { - $this->mMemc->delete( $this->getOptionsKey( $page ) ); + $this->cache->delete( $this->getOptionsKey( $page ) ); } /** @@ -190,7 +190,7 @@ class ParserCache { } // Determine the options which affect this article - $optionsKey = $this->mMemc->get( + $optionsKey = $this->cache->get( $this->getOptionsKey( $article ), BagOStuff::READ_VERIFIED ); if ( $optionsKey instanceof CacheTime ) { if ( $useOutdated < self::USE_EXPIRED && $optionsKey->expired( $article->getTouched() ) ) { @@ -257,7 +257,7 @@ class ParserCache { $casToken = null; /** @var ParserOutput $value */ - $value = $this->mMemc->get( $parserOutputKey, BagOStuff::READ_VERIFIED ); + $value = $this->cache->get( $parserOutputKey, BagOStuff::READ_VERIFIED ); if ( !$value ) { wfDebug( "ParserOutput cache miss.\n" ); $this->incrementStats( $article, "miss.absent" ); @@ -319,7 +319,7 @@ class ParserCache { } $expire = $parserOutput->getCacheExpiry(); - if ( $expire > 0 && !$this->mMemc instanceof EmptyBagOStuff ) { + if ( $expire > 0 && !$this->cache instanceof EmptyBagOStuff ) { $cacheTime = $cacheTime ?: wfTimestampNow(); if ( !$revId ) { $revision = $page->getRevision(); @@ -350,10 +350,15 @@ class ParserCache { wfDebug( $msg ); // Save the parser output - $this->mMemc->set( $parserOutputKey, $parserOutput, $expire ); + $this->cache->set( + $parserOutputKey, + $parserOutput, + $expire, + BagOStuff::WRITE_ALLOW_SEGMENTS + ); // ...and its pointer - $this->mMemc->set( $this->getOptionsKey( $page ), $optionsKey, $expire ); + $this->cache->set( $this->getOptionsKey( $page ), $optionsKey, $expire ); Hooks::run( 'ParserCacheSaveComplete', @@ -372,6 +377,6 @@ class ParserCache { * @return BagOStuff */ public function getCacheStorage() { - return $this->mMemc; + return $this->cache; } }