MediaWiki  master
Parser\RevisionOutputCache Class Reference

Cache for ParserOutput objects. More...

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. More...
 
 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. More...
 
 makeParserOutputKeyOptionalRevId (RevisionRecord $revision, ParserOptions $options, array $usedOptions=null)
 Get a key that will be used for locks or pool counter. More...
 
 save (ParserOutput $output, RevisionRecord $revision, ParserOptions $parserOptions, string $cacheTime=null)
 

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()

Parser\RevisionOutputCache::__construct ( string  $name,
WANObjectCache  $cache,
int  $cacheExpiry,
string  $cacheEpoch,
JsonCodec  $jsonCodec,
IBufferingStatsdDataFactory  $stats,
LoggerInterface  $logger 
)
Parameters
string$name
WANObjectCache$cache
int$cacheExpiryExpiry for ParserOutput in $cache.
string$cacheEpochAnything before this timestamp is invalidated
JsonCodec$jsonCodec
IBufferingStatsdDataFactory$stats
LoggerInterface$logger

Definition at line 84 of file RevisionOutputCache.php.

References $cache.

Member Function Documentation

◆ get()

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|false False on failure

Definition at line 184 of file RevisionOutputCache.php.

◆ makeParserOutputKey()

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.

If there is a possibility the revision does not have a revision id, use makeParserOutputKeyOptionalRevId() instead.

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 129 of file RevisionOutputCache.php.

◆ makeParserOutputKeyOptionalRevId()

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

Get a key that will be used for locks or pool counter.

Similar to makeParserOutputKey except the revision id might be null, in which case it is unsafe to cache, but still needs a key for things like poolcounter.

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 162 of file RevisionOutputCache.php.

◆ save()

Parser\RevisionOutputCache::save ( ParserOutput  $output,
RevisionRecord  $revision,
ParserOptions  $parserOptions,
string  $cacheTime = null 
)
Parameters
ParserOutput$output
RevisionRecord$revision
ParserOptions$parserOptions
string | null$cacheTimeTS_MW timestamp when the output was generated

Definition at line 229 of file RevisionOutputCache.php.

References ParserOutput\addCacheMessage(), CacheTime\getCacheExpiry(), ParserOutput\hasText(), ParserOptions\isSafeToCache(), CacheTime\setCacheRevisionId(), CacheTime\setCacheTime(), ParserOutput\setTimestamp(), CacheTime\updateCacheExpiry(), and wfTimestampNow().


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