Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache Class Reference

Caches messages of file based message group source file. More...

Public Member Functions

 __construct (FileBasedMessageGroup $group, string $languageCode, string $cacheFilePath)
 Contructs a new cache object for given group and language code.
 
 exists ()
 Returns whether cache exists for this language and group.
 
 getKeys ()
 Returns list of message keys that are stored.
 
 getTimestamp ()
 Returns timestamp in unix-format about when this cache was first created.
 
 getUpdateTimestamp ()
 
 get (string $key)
 Get an item from the cache.
 
 getAuthors ()
 Get a list of authors.
 
 getExtra ()
 Get other data cached from the file format class.
 
 create ( $created=false)
 Populates the cache from current state of the source file.
 
 isValid (&$reason)
 Checks whether the cache still reflects the source file.
 
 invalidate ()
 

Public Attributes

const NO_SOURCE = 1
 
const NO_CACHE = 2
 
const CHANGED = 3
 

Protected Member Functions

 open ()
 Open the cache for reading.
 
 close ()
 Close the cache from reading.
 
 getCacheFilePath ()
 Returns full path to the cache file.
 

Detailed Description

Caches messages of file based message group source file.

Can also track that the cache is up to date. Parsing the source files can be slow, so constructing CDB cache makes accessing that data constant speed regardless of the actual format. This also avoid having to deal with potentially unsafe external files during web requests.

Author
Niklas Laxström @license GPL-2.0-or-later

Definition at line 23 of file MessageGroupCache.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::__construct ( FileBasedMessageGroup $group,
string $languageCode,
string $cacheFilePath )

Contructs a new cache object for given group and language code.

Definition at line 34 of file MessageGroupCache.php.

Member Function Documentation

◆ close()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::close ( )
protected

Close the cache from reading.

Definition at line 252 of file MessageGroupCache.php.

◆ create()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::create ( $created = false)

Populates the cache from current state of the source file.

Parameters
string | false$createdUnix timestamp when the cache is created (for automatic updates).

Definition at line 110 of file MessageGroupCache.php.

◆ exists()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::exists ( )

Returns whether cache exists for this language and group.

Definition at line 45 of file MessageGroupCache.php.

◆ get()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::get ( string $key)

Get an item from the cache.

Returns
string|false

Definition at line 86 of file MessageGroupCache.php.

◆ getAuthors()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::getAuthors ( )

Get a list of authors.

Returns
string[]

Definition at line 94 of file MessageGroupCache.php.

◆ getCacheFilePath()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::getCacheFilePath ( )
protected

Returns full path to the cache file.

Definition at line 260 of file MessageGroupCache.php.

◆ getExtra()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::getExtra ( )

Get other data cached from the file format class.

Definition at line 101 of file MessageGroupCache.php.

◆ getKeys()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::getKeys ( )

Returns list of message keys that are stored.

Returns
string[] Message keys that can be passed one-by-one to get() method.

Definition at line 53 of file MessageGroupCache.php.

◆ getTimestamp()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::getTimestamp ( )

Returns timestamp in unix-format about when this cache was first created.

Returns
string|false Unix timestamp.

Definition at line 73 of file MessageGroupCache.php.

◆ getUpdateTimestamp()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::getUpdateTimestamp ( )
Returns
string|false Unix timestamp.

Definition at line 78 of file MessageGroupCache.php.

◆ invalidate()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::invalidate ( )

Definition at line 224 of file MessageGroupCache.php.

◆ isValid()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::isValid ( & $reason)

Checks whether the cache still reflects the source file.

It uses multiple conditions to speed up the checking from file modification timestamps to hashing.

Parameters
int&$reason(output) The reason for the cache being invalid. This parameter is an output-only parameter and doesn't need to be initialized by callers. It will be populated with the reason when the function returns.
Returns
bool Whether the cache is up to date.

Definition at line 151 of file MessageGroupCache.php.

◆ open()

MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::open ( )
protected

Open the cache for reading.

Definition at line 245 of file MessageGroupCache.php.

Member Data Documentation

◆ CHANGED

const MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::CHANGED = 3

Definition at line 26 of file MessageGroupCache.php.

◆ NO_CACHE

const MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::NO_CACHE = 2

Definition at line 25 of file MessageGroupCache.php.

◆ NO_SOURCE

const MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::NO_SOURCE = 1

Definition at line 24 of file MessageGroupCache.php.


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