Make ParserCache use CachedBagOStuff
Bug: T269593 Change-Id: I21e6e39eccad22b781252b142c1e5b079c1ee0b4
This commit is contained in:
parent
66e41027b1
commit
66cc685b45
3 changed files with 15 additions and 6 deletions
|
|
@ -142,6 +142,13 @@ class ParserCache {
|
|||
LoggerInterface $logger,
|
||||
$useJson = false
|
||||
) {
|
||||
if ( !$cache instanceof EmptyBagOStuff && !$cache instanceof CachedBagOStuff ) {
|
||||
$cache = new CachedBagOStuff( $cache, [
|
||||
// Each ParserCache entry uses 2 keys, one for metadata and one for parser output.
|
||||
// So, cache at most 4 different parser outputs in memory. The number was chosen ad hoc.
|
||||
'maxKeys' => 8
|
||||
] );
|
||||
}
|
||||
$this->name = $name;
|
||||
$this->cache = $cache;
|
||||
$this->cacheEpoch = $cacheEpoch;
|
||||
|
|
|
|||
|
|
@ -576,8 +576,7 @@ class ParserCacheTest extends MediaWikiIntegrationTestCase {
|
|||
* @param string $data
|
||||
*/
|
||||
public function testCorruptData( bool $json, string $data ) {
|
||||
$bag = new HashBagOStuff();
|
||||
$cache = $this->createParserCache( null, $bag );
|
||||
$cache = $this->createParserCache( null, new HashBagOStuff() );
|
||||
$cache->setJsonSupport( $json, $json );
|
||||
$parserOutput = new ParserOutput( 'TEST_TEXT' );
|
||||
|
||||
|
|
@ -590,7 +589,7 @@ class ParserCacheTest extends MediaWikiIntegrationTestCase {
|
|||
$parserOutput->getUsedOptions()
|
||||
);
|
||||
|
||||
$bag->set( $outputKey, $data );
|
||||
$cache->getCacheStorage()->set( $outputKey, $data );
|
||||
|
||||
// just make sure we don't crash and burn
|
||||
$this->assertFalse( $cache->get( $this->page, $options1 ) );
|
||||
|
|
@ -607,8 +606,7 @@ class ParserCacheTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testCorruptMetadata() {
|
||||
$this->hideDeprecated( 'ParserCache::getKey' );
|
||||
$bag = new HashBagOStuff();
|
||||
$cache = $this->createParserCache( null, $bag );
|
||||
$cache = $this->createParserCache( null, new HashBagOStuff() );
|
||||
$parserOutput = new ParserOutput( 'TEST_TEXT' );
|
||||
|
||||
$options1 = ParserOptions::newCanonical( 'canonical' );
|
||||
|
|
@ -618,7 +616,7 @@ class ParserCacheTest extends MediaWikiIntegrationTestCase {
|
|||
$this->page
|
||||
);
|
||||
|
||||
$bag->set( $optionsKey, 'bad data' );
|
||||
$cache->getCacheStorage()->set( $optionsKey, 'bad data' );
|
||||
|
||||
// just make sure we don't crash and burn
|
||||
$this->assertNull( $cache->getMetadata( $this->page ) );
|
||||
|
|
|
|||
|
|
@ -24,4 +24,8 @@ class ParserCacheFactoryTest extends MediaWikiUnitTestCase {
|
|||
// $name
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function getIgnoredParamNames() {
|
||||
return [ 'cacheBackend', 'hookContainer' ];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue