MediaWiki REL1_37
MediaWiki\Parser\RevisionOutputCache Class Reference

Cache for ParserOutput objects. More...

Collaboration diagram for MediaWiki\Parser\RevisionOutputCache:

Public Member Functions

 __construct (string $name, WANObjectCache $cache, int $cacheExpiry, string $cacheEpoch, JsonCodec $jsonCodec, IBufferingStatsdDataFactory $stats, LoggerInterface $logger)
 
 get (RevisionRecord $revision, ParserOptions $parserOptions)
 Retrieve the ParserOutput from cache.
 
 makeParserOutputKey (RevisionRecord $revision, ParserOptions $options, array $usedOptions=null)
 Get a key that will be used by this cache to store the content for a given page considering the given options and the array of used options.
 
 save (ParserOutput $output, RevisionRecord $revision, ParserOptions $parserOptions, string $cacheTime=null)
 

Private Member Functions

 encodeAsJson (CacheTime $obj, string $key)
 
 incrementStats (RevisionRecord $revision, string $metricSuffix)
 
 restoreFromJson (string $jsonData, string $key, string $expectedClass)
 

Private Attributes

WANObjectCache $cache
 
string $cacheEpoch
 Anything cached prior to this is invalidated.
 
string $cacheExpiry
 Expiry time for cache entries.
 
JsonCodec $jsonCodec
 
LoggerInterface $logger
 
string $name
 The name of this cache.
 
IBufferingStatsdDataFactory $stats
 

Detailed Description

Cache for ParserOutput objects.

The cache is split per ParserOptions.

Since
1.36

Definition at line 44 of file RevisionOutputCache.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Parser\RevisionOutputCache::__construct ( string  $name,
WANObjectCache  $cache,
int  $cacheExpiry,
string  $cacheEpoch,
JsonCodec  $jsonCodec,
IBufferingStatsdDataFactory  $stats,
LoggerInterface  $logger 
)

Member Function Documentation

◆ encodeAsJson()

MediaWiki\Parser\RevisionOutputCache::encodeAsJson ( CacheTime  $obj,
string  $key 
)
private
Parameters
CacheTime$obj
string$key
Returns
string|null

Definition at line 272 of file RevisionOutputCache.php.

◆ get()

MediaWiki\Parser\RevisionOutputCache::get ( RevisionRecord  $revision,
ParserOptions  $parserOptions 
)

Retrieve the ParserOutput from cache.

false if not found or outdated.

Parameters
RevisionRecord$revision
ParserOptions$parserOptions
Returns
ParserOutput|bool False on failure

Definition at line 148 of file RevisionOutputCache.php.

◆ incrementStats()

MediaWiki\Parser\RevisionOutputCache::incrementStats ( RevisionRecord  $revision,
string  $metricSuffix 
)
private
Parameters
RevisionRecord$revision
string$metricSuffix

Definition at line 106 of file RevisionOutputCache.php.

◆ makeParserOutputKey()

MediaWiki\Parser\RevisionOutputCache::makeParserOutputKey ( RevisionRecord  $revision,
ParserOptions  $options,
array  $usedOptions = null 
)

Get a key that will be used by this cache to store the content for a given page considering the given options and the array of used options.

Warning
The exact format of the key is considered internal and is subject to change, thus should not be used as storage or long-term caching key. This is intended to be used for logging or keying something transient.
Parameters
RevisionRecord$revision
ParserOptions$options
array | null$usedOptionscurrently ignored
Returns
string
Access: internal

Definition at line 126 of file RevisionOutputCache.php.

◆ restoreFromJson()

MediaWiki\Parser\RevisionOutputCache::restoreFromJson ( string  $jsonData,
string  $key,
string  $expectedClass 
)
private
Parameters
string$jsonData
string$key
string$expectedClass
Returns
CacheTime|ParserOutput|null

Definition at line 252 of file RevisionOutputCache.php.

◆ save()

MediaWiki\Parser\RevisionOutputCache::save ( ParserOutput  $output,
RevisionRecord  $revision,
ParserOptions  $parserOptions,
string  $cacheTime = null 
)

Member Data Documentation

◆ $cache

WANObjectCache MediaWiki\Parser\RevisionOutputCache::$cache
private

◆ $cacheEpoch

string MediaWiki\Parser\RevisionOutputCache::$cacheEpoch
private

Anything cached prior to this is invalidated.

Definition at line 57 of file RevisionOutputCache.php.

Referenced by MediaWiki\Parser\RevisionOutputCache\__construct().

◆ $cacheExpiry

string MediaWiki\Parser\RevisionOutputCache::$cacheExpiry
private

Expiry time for cache entries.

Definition at line 64 of file RevisionOutputCache.php.

Referenced by MediaWiki\Parser\RevisionOutputCache\__construct().

◆ $jsonCodec

JsonCodec MediaWiki\Parser\RevisionOutputCache::$jsonCodec
private

◆ $logger

LoggerInterface MediaWiki\Parser\RevisionOutputCache::$logger
private

◆ $name

string MediaWiki\Parser\RevisionOutputCache::$name
private

The name of this cache.

Used as a root of the cache key.

Definition at line 47 of file RevisionOutputCache.php.

Referenced by MediaWiki\Parser\RevisionOutputCache\__construct().

◆ $stats

IBufferingStatsdDataFactory MediaWiki\Parser\RevisionOutputCache::$stats
private

The documentation for this class was generated from the following file: