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

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

Public Member Functions

 __construct (FileBasedMessageGroup $group, string $code, 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 ( $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.
 

Protected Attributes

 $group
 
 $cache
 
 $code
 

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.

Definition at line 20 of file MessageGroupCache.php.

Constructor & Destructor Documentation

◆ __construct()

MessageGroupCache::__construct ( FileBasedMessageGroup $group,
string $code,
string $cacheFilePath )

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

Parameters
FileBasedMessageGroup$group
string$codeLanguage code.
string$cacheFilePath

Definition at line 40 of file MessageGroupCache.php.

Member Function Documentation

◆ close()

MessageGroupCache::close ( )
protected

Close the cache from reading.

Definition at line 274 of file MessageGroupCache.php.

◆ create()

MessageGroupCache::create ( $created = false)

Populates the cache from current state of the source file.

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

Definition at line 128 of file MessageGroupCache.php.

◆ exists()

MessageGroupCache::exists ( )

Returns whether cache exists for this language and group.

Returns
bool

Definition at line 54 of file MessageGroupCache.php.

◆ get()

MessageGroupCache::get ( $key)

Get an item from the cache.

Parameters
string$key
Returns
string

Definition at line 99 of file MessageGroupCache.php.

◆ getAuthors()

MessageGroupCache::getAuthors ( )

Get a list of authors.

Returns
string[]
Since
2020.04

Definition at line 108 of file MessageGroupCache.php.

◆ getCacheFilePath()

MessageGroupCache::getCacheFilePath ( )
protected

Returns full path to the cache file.

Returns
string

Definition at line 285 of file MessageGroupCache.php.

◆ getExtra()

MessageGroupCache::getExtra ( )

Get other data cached from the file format class.

Returns
array
Since
2020.04

Definition at line 119 of file MessageGroupCache.php.

◆ getKeys()

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 62 of file MessageGroupCache.php.

◆ getTimestamp()

MessageGroupCache::getTimestamp ( )

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

Returns
string Unix timestamp.

Definition at line 82 of file MessageGroupCache.php.

◆ getUpdateTimestamp()

MessageGroupCache::getUpdateTimestamp ( )

...

Returns
string Unix timestamp.

Definition at line 90 of file MessageGroupCache.php.

◆ invalidate()

MessageGroupCache::invalidate ( )

Definition at line 239 of file MessageGroupCache.php.

◆ isValid()

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
Returns
bool Whether the cache is up to date.

Definition at line 166 of file MessageGroupCache.php.

◆ open()

MessageGroupCache::open ( )
protected

Open the cache for reading.

Returns
Reader

Definition at line 263 of file MessageGroupCache.php.

Member Data Documentation

◆ $cache

MessageGroupCache::$cache
protected

Definition at line 28 of file MessageGroupCache.php.

◆ $code

MessageGroupCache::$code
protected

Definition at line 30 of file MessageGroupCache.php.

◆ $group

MessageGroupCache::$group
protected

Definition at line 26 of file MessageGroupCache.php.

◆ CHANGED

const MessageGroupCache::CHANGED = 3

Definition at line 23 of file MessageGroupCache.php.

◆ NO_CACHE

const MessageGroupCache::NO_CACHE = 2

Definition at line 22 of file MessageGroupCache.php.

◆ NO_SOURCE

const MessageGroupCache::NO_SOURCE = 1

Definition at line 21 of file MessageGroupCache.php.


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