|
MediaWiki master
|
Localisation cache storage based on PHP files and static arrays. More...
Inherits MediaWiki\Language\LCStore.

Public Member Functions | |||||||
| __construct (array $conf=[]) | |||||||
| finishWrite () | |||||||
| Finish a cache write transaction. | |||||||
| get ( $code, $key) | |||||||
| Get a value.
| |||||||
| lateFallback () | |||||||
Can this cache type delay fallback lookups to read time?Returning true will cause the fallbacks to be skipped when recaching data, and instead performed via multiple reads if necessary at runtime.This is best when performing lookups is extremely low-cost, such as LCStoreStaticArray with the lateFallback option.When reading from disk or network, trading off the space for fewer lookups may still be a win. Returning false will keep the classic behavior of pre-filling all the fallback chains for each language. | |||||||
| set ( $key, $value) | |||||||
Set a key to a given value.startWrite() must be called before this is called, and finishWrite() must be called after.
| |||||||
| startWrite ( $code) | |||||||
Start a cache write transaction.
| |||||||
Static Public Member Functions | |
| static | decode ( $encoded) |
| Decode something that was encoded with 'encode'. | |
| static | encode ( $value) |
| Encodes a value into an array format. | |
Protected Member Functions | |
| atomicWrite (string $fileName, array $data) | |
| getMessageKey (string $key) | |
Localisation cache storage based on PHP files and static arrays.
This is meant to leverage the PHP opcache and may require increasing memory sizes on a production site that handles many languages routinely.
These php.ini settings are sufficient for some local testing, but would be rather too small for Wikimedia production which has many localised extensions installed.
opcache.memory_consumption=1024opcache.interned_strings_buffer=256As of MediaWiki 1.46, this cache backend does two important things differently from the CDB backend:
Late fallback: tells LocalisationCache to do late fallback/merge logic at read time, reducing redundant data in the .l10n.php files for a slight, hard to measure runtime cost in looking up a few more arrays.
This gives a massive reduction in both disk usage and opcode cache usage versus pre-merging all the fallbacks: strings are already deduplicated in the opcache's string interning but const array hashmap data is not!
messages array is reconstructed to avoid duplicating the prefix 'messages:' thousands of times and make the key list cheap to load.Additionally, LCStoreStaticArray silently drops the 'preload' and 'preloadMessages' data duplication in each language, as it's cheap to query the messages individually.
The resulting cache files are about ~80% smaller than under 1.45 due to the drop in redundant data, and compress very well for delta copies.
Older cached data from before 1.46 is backwards-compatible on read.
Definition at line 55 of file LCStoreStaticArray.php.
| MediaWiki\Language\LCStoreStaticArray::__construct | ( | array | $conf = [] | ) |
Definition at line 72 of file LCStoreStaticArray.php.
|
protected |
Definition at line 195 of file LCStoreStaticArray.php.
Referenced by MediaWiki\Language\LCStoreStaticArray\finishWrite().
|
static |
Decode something that was encoded with 'encode'.
| mixed | $encoded |
| RuntimeException |
Definition at line 163 of file LCStoreStaticArray.php.
|
static |
Encodes a value into an array format.
| mixed | $value |
| RuntimeException |
Definition at line 136 of file LCStoreStaticArray.php.
Referenced by MediaWiki\Language\LCStoreStaticArray\set().
| MediaWiki\Language\LCStoreStaticArray::finishWrite | ( | ) |
Finish a cache write transaction.
Implements MediaWiki\Language\LCStore.
Definition at line 186 of file LCStoreStaticArray.php.
References MediaWiki\Language\LCStoreStaticArray\atomicWrite().
| MediaWiki\Language\LCStoreStaticArray::get | ( | $code, | |
| $key ) |
Get a value.
Implements MediaWiki\Language\LCStore.
Definition at line 217 of file LCStoreStaticArray.php.
|
protected |
Definition at line 209 of file LCStoreStaticArray.php.
| MediaWiki\Language\LCStoreStaticArray::lateFallback | ( | ) |
Can this cache type delay fallback lookups to read time?Returning true will cause the fallbacks to be skipped when recaching data, and instead performed via multiple reads if necessary at runtime.This is best when performing lookups is extremely low-cost, such as LCStoreStaticArray with the lateFallback option.When reading from disk or network, trading off the space for fewer lookups may still be a win. Returning false will keep the classic behavior of pre-filling all the fallback chains for each language.
Implements MediaWiki\Language\LCStore.
Definition at line 261 of file LCStoreStaticArray.php.
| MediaWiki\Language\LCStoreStaticArray::set | ( | $key, | |
| $value ) |
Set a key to a given value.startWrite() must be called before this is called, and finishWrite() must be called after.
| string | $key | |
| mixed | $value |
Implements MediaWiki\Language\LCStore.
Definition at line 91 of file LCStoreStaticArray.php.
References MediaWiki\Language\LCStoreStaticArray\encode().
| MediaWiki\Language\LCStoreStaticArray::startWrite | ( | $code | ) |
Start a cache write transaction.
| string | $code | Language code |
Implements MediaWiki\Language\LCStore.
Definition at line 77 of file LCStoreStaticArray.php.
References wfMkdirParents().