34 private $fileCache = [];
41 private $mruLangs = [];
46 private $maxLoadedLangs = 10;
54 $serialize = $fileType ===
'core';
55 if ( !isset( $this->fileCache[$fileName][$fileType] ) ) {
56 $data = parent::readPHPFile( $fileName, $fileType );
59 $encData = serialize(
$data );
64 $this->fileCache[$fileName][$fileType] = $encData;
67 } elseif ( $serialize ) {
68 return unserialize( $this->fileCache[$fileName][$fileType] );
70 return $this->fileCache[$fileName][$fileType];
80 unset( $this->mruLangs[$code] );
81 $this->mruLangs[$code] =
true;
83 return parent::getItem( $code, $key );
93 unset( $this->mruLangs[$code] );
94 $this->mruLangs[$code] =
true;
96 return parent::getSubitem( $code, $key, $subkey );
103 parent::recache( $code );
104 unset( $this->mruLangs[$code] );
105 $this->mruLangs[$code] =
true;
113 unset( $this->mruLangs[$code] );
114 parent::unload( $code );
121 while ( count( $this->data ) > $this->maxLoadedLangs && count( $this->mruLangs ) ) {
122 $code = array_key_first( $this->mruLangs );
123 wfDebug( __METHOD__ .
": unloading $code" );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
LocalisationCache optimised for loading many languages at once.
trimCache()
Unload cached languages until there are less than $this->maxLoadedLangs.
getSubitem( $code, $key, $subkey)
readPHPFile( $fileName, $fileType)
Caching for the contents of localisation files.
array< string, array > $data
The cache data.