MessageCache
This is Wikimedia-specific documentation for the MessageCache system.
The MediaWiki message cache stores text from the MediaWiki namespace for use during wfMsg() etc. When text is not present in the MediaWiki namespace, it calls the LocalisationCache instead, and passes the result back to the caller.
The message cache has 3 layers of caching:
- An in-process cache stored in MessageCache::singleton()->mCache
- A local cache, stored in $wgCacheDirectory (/tmp/mw-cache-1.18). The filename is of the form messages-<wiki>-<code>.
- A shared cache, stored in memcached
To ensure that the local caches are properly synchronised, there is a content hash stored at the start of the local cache file, which is checked against a hash stored in memcached.
The message cache is not normally completely rebuilt. On edit, MessageCache::replace() is called, which modifies the shared cache, replacing a single key. The hash is updated and all other servers reload their caches from the new shared cache.
Memcached keys:
- <wiki>:messages:<code>
- Stores the message texts below a certain size ($wgMaxMsgCacheEntrySize). This can expire without ill effects as long as the hash key is still present.
- <wiki>:messages:hash:<code>
- The hash key for the local message cache and <wiki>:messages:<code>
- <wiki>:messages:individual:<title>
- Stores the text of an individual message which was larger than $wgMaxMsgCacheEntrySize
How to
- To clear the cache
- mwscript eval.php --wiki=<wiki>
- MessageCache::singleton()->clear();