MediaWiki  REL1_20
MessageCache Class Reference

Message cache Performs various MediaWiki namespace-related functions. More...

List of all members.

Public Member Functions

 __construct ($memCached, $useDB, $expiry)
 clear ()
 Clear all stored messages.
 disable ()
 enable ()
 escapeForScript ($string)
 figureMessage ($key)
 get ($key, $useDB=true, $langcode=true, $isFullKey=false)
 Get a message from either the content language or the user language.
 getAllMessageKeys ($code)
 Get all message keys stored in the message cache for a given language.
 getMostUsedMessages ()
 getMsgFromNamespace ($title, $code)
 Get a message from the MediaWiki namespace, with caching.
 getParser ()
 getParserOptions ()
 ParserOptions is lazy initialised.
 load ($code=false)
 Loads messages from caches or from database in this order: (1) local message cache (if $wgUseLocalMessageCache is enabled) (2) memcached (3) from the database.
 loadFromDB ($code)
 Loads cacheable messages from the database.
 loadFromLocal ($hash, $code)
 Try to load the cache from a local file.
 lock ($key)
 Represents a write lock on the messages key.
 parse ($text, $title=null, $linestart=true, $interface=false, $language=null)
 replace ($title, $text)
 Updates cache as necessary when message page is changed.
 saveToLocal ($serialized, $hash, $code)
 Save the cache to a local file.
 saveToScript ($array, $hash, $code)
 setCache ($cache, $code)
 Set the cache to $cache, if it is valid.
 transform ($message, $interface=false, $language=null, $title=null)
 unlock ($key)

Static Public Member Functions

static destroyInstance ()
 Destroy the singleton instance.
static logMessages ()
static singleton ()
 Get the signleton instance of this class.

Public Attributes

 $mParser

Protected Member Functions

 saveToCaches ($cache, $memc=true, $code=false)
 Shortcut to update caches.

Protected Attributes

 $mCache
 Process local cache of loaded messages that are defined in MediaWiki namespace.
 $mDisable
 $mExpiry
 Lifetime for cache, used by object caching.
bool $mInParser = false
 $mLoadedLanguages = array()
 Variable for tracking which variables are already loaded.
 $mParserOptions
 Message cache has it's own parser which it uses to transform messages.
 $mRequestedMessages = array()
 Used for automatic detection of most used messages.

Static Protected Attributes

static $mAdaptiveDataAge = 604800
 How long the message request counts are stored.
static $mAdaptiveInclusionThreshold = 0.05
 Filter the tail of less used messages that are requested more seldom than this factor times the number of request of most requested message.

Static Private Attributes

static $instance

Detailed Description

Message cache Performs various MediaWiki namespace-related functions.

Definition at line 37 of file MessageCache.php.


Constructor & Destructor Documentation

MessageCache::__construct ( memCached,
useDB,
expiry 
)

Definition at line 116 of file MessageCache.php.

References wfGetCache().


Member Function Documentation

Clear all stored messages.

Mainly used after a mass rebuild.

Definition at line 890 of file MessageCache.php.

static MessageCache::destroyInstance ( ) [static]

Destroy the singleton instance.

Since:
1.18

Definition at line 112 of file MessageCache.php.

Referenced by NewParserTest\setupGlobals().

Definition at line 879 of file MessageCache.php.

Definition at line 883 of file MessageCache.php.

Definition at line 243 of file MessageCache.php.

Referenced by saveToScript().

Parameters:
$key
Returns:
array

Definition at line 905 of file MessageCache.php.

MessageCache::get ( key,
useDB = true,
langcode = true,
isFullKey = false 
)

Get a message from either the content language or the user language.

Parameters:
$keyString: the message cache key
$useDBBoolean: get the message from the DB, false to use only the localisation
$langcodeString: code of the language to get the message for, if it is a valid code create a language for that language, if it is a string but not a valid code then make a basic language object, if it is a false boolean then use the current users language (as a fallback for the old parameter functionality), or if it is a true boolean then use the wikis content language (also as a fallback).
$isFullKeyBoolean: specifies whether $key is a two part key "msg/lang".
Returns:
string|bool

Definition at line 611 of file MessageCache.php.

Get all message keys stored in the message cache for a given language.

If $code is the content language code, this will return all message keys for which MediaWiki:msgkey exists. If $code is another language code, this will ONLY return message keys for which MediaWiki:msgkey/$code exists.

Parameters:
$codestring
Returns:
array of message keys (strings)

Definition at line 1005 of file MessageCache.php.

Returns:
array

Definition at line 964 of file MessageCache.php.

MessageCache::getMsgFromNamespace ( title,
code 
)

Get a message from the MediaWiki namespace, with caching.

The key must first be converted to two-part lang/msg form if necessary.

Parameters:
$titleString: Message cache key with initial uppercase letter.
$codeString: code denoting the language to try.
Returns:
string|bool False on failure

Definition at line 719 of file MessageCache.php.

Returns:
Parser

Definition at line 824 of file MessageCache.php.

ParserOptions is lazy initialised.

Returns:
ParserOptions

Definition at line 131 of file MessageCache.php.

MessageCache::load ( code = false)

Loads messages from caches or from database in this order: (1) local message cache (if $wgUseLocalMessageCache is enabled) (2) memcached (3) from the database.

When succesfully loading from (2) or (3), all higher level caches are updated for the newest version.

Nothing is loaded if member variable mDisable is true, either manually set by calling code or if message loading fails (is this possible?).

Returns true if cache is already populated or it was succesfully populated, or false if populating empty cache fails. Also returns true if MessageCache is disabled.

Parameters:
$codeString: language to which load messages
Returns:
bool

Definition at line 282 of file MessageCache.php.

Loads cacheable messages from the database.

Messages bigger than $wgMaxMsgCacheEntrySize are assigned a special value, and are loaded on-demand from the database later.

Parameters:
$codeString: language code.
Returns:
Array: loaded messages for storing in caches.

Definition at line 393 of file MessageCache.php.

MessageCache::loadFromLocal ( hash,
code 
)

Try to load the cache from a local file.

Actual format of the file depends on the $wgLocalMessageCacheSerialized setting.

Parameters:
$hashString: the hash of contents, to check validity.
$codeMixed: Optional language code, see documenation of load().
Returns:
bool on failure.

Definition at line 148 of file MessageCache.php.

MessageCache::lock ( key)

Represents a write lock on the messages key.

Parameters:
$keystring
Returns:
Boolean: success

Definition at line 578 of file MessageCache.php.

MessageCache::parse ( text,
title = null,
linestart = true,
interface = false,
language = null 
)
Parameters:
$textstring
$titleTitle
$linestartbool
$interfacebool
$language
Returns:
ParserOutput

Definition at line 849 of file MessageCache.php.

MessageCache::replace ( title,
text 
)

Updates cache as necessary when message page is changed.

Parameters:
$titleString: name of the page changed.
$textMixed: new contents of the page.

Definition at line 478 of file MessageCache.php.

MessageCache::saveToCaches ( cache,
memc = true,
code = false 
) [protected]

Shortcut to update caches.

Parameters:
$cacheArray: cached messages with a version.
$memcBool: Wether to update or not memcache.
$codeString: Language code.
Returns:
bool on somekind of error.

Definition at line 543 of file MessageCache.php.

MessageCache::saveToLocal ( serialized,
hash,
code 
)

Save the cache to a local file.

Definition at line 192 of file MessageCache.php.

MessageCache::saveToScript ( array,
hash,
code 
)
MessageCache::setCache ( cache,
code 
)

Set the cache to $cache, if it is valid.

Otherwise set the cache to false.

Returns:
bool

Definition at line 254 of file MessageCache.php.

MessageCache::transform ( message,
interface = false,
language = null,
title = null 
)
Parameters:
$messagestring
$interfacebool
$language
$titleTitle
Returns:
string

Definition at line 796 of file MessageCache.php.

Definition at line 587 of file MessageCache.php.


Member Data Documentation

MessageCache::$instance [static, private]

Definition at line 87 of file MessageCache.php.

MessageCache::$mAdaptiveDataAge = 604800 [static, protected]

How long the message request counts are stored.

Longer period gives better sample, but also takes longer to adapt changes. The counts are aggregrated per day, regardless of the value of this variable.

Definition at line 72 of file MessageCache.php.

Referenced by logMessages().

MessageCache::$mAdaptiveInclusionThreshold = 0.05 [static, protected]

Filter the tail of less used messages that are requested more seldom than this factor times the number of request of most requested message.

These messages are not loaded in the default set, but are still cached individually on demand with the normal cache expiry time.

Definition at line 80 of file MessageCache.php.

MessageCache::$mCache [protected]

Process local cache of loaded messages that are defined in MediaWiki namespace.

First array level is a language code, second level is message key and the values are either message content prefixed with space, or !NONEXISTENT for negative caching.

Definition at line 45 of file MessageCache.php.

MessageCache::$mDisable [protected]

Definition at line 48 of file MessageCache.php.

MessageCache::$mExpiry [protected]

Lifetime for cache, used by object caching.

Definition at line 51 of file MessageCache.php.

bool MessageCache::$mInParser = false [protected]

Definition at line 91 of file MessageCache.php.

MessageCache::$mLoadedLanguages = array() [protected]

Variable for tracking which variables are already loaded.

Definition at line 60 of file MessageCache.php.

MessageCache::$mParser

Definition at line 57 of file MessageCache.php.

MessageCache::$mParserOptions [protected]

Message cache has it's own parser which it uses to transform messages.

Definition at line 57 of file MessageCache.php.

MessageCache::$mRequestedMessages = array() [protected]

Used for automatic detection of most used messages.

Definition at line 65 of file MessageCache.php.


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