MediaWiki REL1_37
ParserCacheFactory.php
Go to the documentation of this file.
1<?php
23
24use BagOStuff;
30use ParserCache;
31use Psr\Log\LoggerInterface;
32use TitleFactory;
34
41
43 public const DEFAULT_NAME = 'pcache';
44
47
50
53
55 private $jsonCodec;
56
58 private $stats;
59
61 private $logger;
62
65
68
70 private $parserCaches = [];
71
74
76 private $options;
77
81 public const CONSTRUCTOR_OPTIONS = [
82 'ParserCacheUseJson', // Temporary feature flag, remove before 1.36 is released.
83 'CacheEpoch',
84 'OldRevisionParserCacheExpireTime',
85 ];
86
98 public function __construct(
104 LoggerInterface $logger,
108 ) {
109 $this->parserCacheBackend = $parserCacheBackend;
110 $this->revisionOutputCacheBackend = $revisionOutputCacheBackend;
111 $this->hookContainer = $hookContainer;
112 $this->jsonCodec = $jsonCodec;
113 $this->stats = $stats;
114 $this->logger = $logger;
115
116 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
117 $this->options = $options;
118 $this->titleFactory = $titleFactory;
119 $this->wikiPageFactory = $wikiPageFactory;
120 }
121
127 public function getParserCache( string $name ): ParserCache {
128 if ( !isset( $this->parserCaches[$name] ) ) {
129 $this->logger->debug( "Creating ParserCache instance for {$name}" );
130 $cache = new ParserCache(
131 $name,
132 $this->parserCacheBackend,
133 $this->options->get( 'CacheEpoch' ),
134 $this->hookContainer,
135 $this->jsonCodec,
136 $this->stats,
137 $this->logger,
138 $this->titleFactory,
139 $this->wikiPageFactory,
140 $this->options->get( 'ParserCacheUseJson' )
141 );
142
143 $this->parserCaches[$name] = $cache;
144 }
145 return $this->parserCaches[$name];
146 }
147
153 public function getRevisionOutputCache( string $name ): RevisionOutputCache {
154 if ( !isset( $this->revisionOutputCaches[$name] ) ) {
155 $this->logger->debug( "Creating RevisionOutputCache instance for {$name}" );
157 $name,
158 $this->revisionOutputCacheBackend,
159 $this->options->get( 'OldRevisionParserCacheExpireTime' ),
160 $this->options->get( 'CacheEpoch' ),
161 $this->jsonCodec,
162 $this->stats,
163 $this->logger
164 );
165
166 $this->revisionOutputCaches[$name] = $cache;
167 }
168 return $this->revisionOutputCaches[$name];
169 }
170}
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
Definition Setup.php:88
Class representing a cache/ephemeral data store.
Definition BagOStuff.php:86
A class for passing options to services.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
__construct(BagOStuff $parserCacheBackend, WANObjectCache $revisionOutputCacheBackend, HookContainer $hookContainer, JsonCodec $jsonCodec, IBufferingStatsdDataFactory $stats, LoggerInterface $logger, ServiceOptions $options, TitleFactory $titleFactory, WikiPageFactory $wikiPageFactory)
IBufferingStatsdDataFactory $stats
getParserCache(string $name)
Get a ParserCache instance by $name.
getRevisionOutputCache(string $name)
Get a RevisionOutputCache instance by $name.
Cache for ParserOutput objects.
Cache for ParserOutput objects corresponding to the latest page revisions.
Creates Title objects.
Multi-datacenter aware caching interface.
MediaWiki adaptation of StatsdDataFactory that provides buffering functionality.
$cache
Definition mcc.php:33