MediaWiki  master
Parser\RevisionOutputCache Class Reference

Cache for ParserOutput objects. More...

Collaboration diagram for 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. 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...
 
 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. More...
 
string $cacheExpiry
 Expiry time for cache entries. More...
 
JsonCodec $jsonCodec
 
LoggerInterface $logger
 
string $name
 The name of this cache. More...
 
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()

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 Parser\RevisionOutputCache\$cache, Parser\RevisionOutputCache\$cacheEpoch, Parser\RevisionOutputCache\$cacheExpiry, Parser\RevisionOutputCache\$jsonCodec, Parser\RevisionOutputCache\$logger, Parser\RevisionOutputCache\$name, and Parser\RevisionOutputCache\$stats.

Member Function Documentation

◆ encodeAsJson()

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

Definition at line 272 of file RevisionOutputCache.php.

Referenced by Parser\RevisionOutputCache\save().

◆ 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|bool False on failure

Definition at line 148 of file RevisionOutputCache.php.

References Parser\RevisionOutputCache\incrementStats(), Parser\RevisionOutputCache\makeParserOutputKey(), and Parser\RevisionOutputCache\restoreFromJson().

◆ incrementStats()

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

Definition at line 106 of file RevisionOutputCache.php.

Referenced by Parser\RevisionOutputCache\get(), and Parser\RevisionOutputCache\save().

◆ 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.

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.

References ParserOptions\allCacheVaryingOptions(), and ParserOptions\optionsHash().

Referenced by Parser\RevisionOutputCache\get(), and Parser\RevisionOutputCache\save().

◆ restoreFromJson()

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.

Referenced by Parser\RevisionOutputCache\get().

◆ save()

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

Member Data Documentation

◆ $cache

WANObjectCache Parser\RevisionOutputCache::$cache
private

Definition at line 50 of file RevisionOutputCache.php.

Referenced by Parser\RevisionOutputCache\__construct().

◆ $cacheEpoch

string Parser\RevisionOutputCache::$cacheEpoch
private

Anything cached prior to this is invalidated.

Definition at line 57 of file RevisionOutputCache.php.

Referenced by Parser\RevisionOutputCache\__construct().

◆ $cacheExpiry

string Parser\RevisionOutputCache::$cacheExpiry
private

Expiry time for cache entries.

Definition at line 64 of file RevisionOutputCache.php.

Referenced by Parser\RevisionOutputCache\__construct().

◆ $jsonCodec

JsonCodec Parser\RevisionOutputCache::$jsonCodec
private

Definition at line 67 of file RevisionOutputCache.php.

Referenced by Parser\RevisionOutputCache\__construct().

◆ $logger

LoggerInterface Parser\RevisionOutputCache::$logger
private

Definition at line 73 of file RevisionOutputCache.php.

Referenced by Parser\RevisionOutputCache\__construct().

◆ $name

string 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 Parser\RevisionOutputCache\__construct().

◆ $stats

IBufferingStatsdDataFactory Parser\RevisionOutputCache::$stats
private

Definition at line 70 of file RevisionOutputCache.php.

Referenced by Parser\RevisionOutputCache\__construct().


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