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. | |
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 23 of file MessageGroupCache.php.
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.
|
protected |
Close the cache from reading.
Definition at line 252 of file MessageGroupCache.php.
MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::create | ( | $created = false | ) |
Populates the cache from current state of the source file.
string | false | $created | Unix timestamp when the cache is created (for automatic updates). |
Definition at line 110 of file MessageGroupCache.php.
MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::exists | ( | ) |
Returns whether cache exists for this language and group.
Definition at line 45 of file MessageGroupCache.php.
MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::get | ( | string | $key | ) |
Get an item from the cache.
Definition at line 86 of file MessageGroupCache.php.
MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::getAuthors | ( | ) |
|
protected |
Returns full path to the cache file.
Definition at line 260 of file MessageGroupCache.php.
MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::getExtra | ( | ) |
Get other data cached from the file format class.
Definition at line 101 of file MessageGroupCache.php.
MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::getKeys | ( | ) |
Returns list of message keys that are stored.
Definition at line 53 of file MessageGroupCache.php.
MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::getTimestamp | ( | ) |
Returns timestamp in unix-format about when this cache was first created.
Definition at line 73 of file MessageGroupCache.php.
MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::getUpdateTimestamp | ( | ) |
Definition at line 78 of file MessageGroupCache.php.
MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::invalidate | ( | ) |
Definition at line 224 of file MessageGroupCache.php.
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.
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. |
Definition at line 151 of file MessageGroupCache.php.
|
protected |
Open the cache for reading.
Definition at line 245 of file MessageGroupCache.php.
const MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::CHANGED = 3 |
Definition at line 26 of file MessageGroupCache.php.
const MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::NO_CACHE = 2 |
Definition at line 25 of file MessageGroupCache.php.
const MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroupCache::NO_SOURCE = 1 |
Definition at line 24 of file MessageGroupCache.php.