* Currently, only one cache instance can exist; callers that
* need multiple backlink cache objects should keep them in scope.
*
- * @param Title $title : Title object to get a backlink cache for
+ * @param Title $title Title object to get a backlink cache for
* @return BacklinkCache
*/
public static function get( Title $title ) {
/**
* Set the Database object to use
*
- * @param $db DatabaseBase
+ * @param DatabaseBase $db
*/
public function setDB( $db ) {
$this->db = $db;
/**
* Get the slave connection to the database
* When non existing, will initialize the connection.
- * @return DatabaseBase object
+ * @return DatabaseBase
*/
protected function getDB() {
if ( !isset( $this->db ) ) {
/**
* Get the backlinks for a given table. Cached in process memory only.
- * @param $table String
- * @param $startId Integer|false
- * @param $endId Integer|false
- * @param $max Integer|INF
- * @param $select string 'all' or 'ids'
+ * @param string $table
+ * @param int|bool $startId
+ * @param int|bool $endId
+ * @param int|INF $max
+ * @param string $select 'all' or 'ids'
* @return ResultWrapper
*/
protected function queryLinks( $table, $startId, $endId, $max, $select = 'all' ) {
/**
* Get the field name prefix for a given table
- * @param $table String
+ * @param string $table
* @throws MWException
* @return null|string
*/
/**
* Get the SQL condition array for selecting backlinks, with a join
* on the page table.
- * @param $table String
+ * @param string $table
* @throws MWException
* @return array|null
*/
/**
* Check if there are any backlinks
- * @param $table String
+ * @param string $table
* @return bool
*/
public function hasLinks( $table ) {
/**
* Get the approximate number of backlinks
- * @param $table String
- * @param $max integer|INF Only count up to this many backlinks
- * @return integer
+ * @param string $table
+ * @param int|INF $max Only count up to this many backlinks
+ * @return int
*/
public function getNumLinks( $table, $max = INF ) {
global $wgMemc, $wgUpdateRowsPerJob;
* Returns an array giving the start and end of each range. The first
* batch has a start of false, and the last batch has an end of false.
*
- * @param string $table the links table name
- * @param $batchSize Integer
- * @return Array
+ * @param string $table The links table name
+ * @param int $batchSize
+ * @return array
*/
public function partition( $table, $batchSize ) {
global $wgMemc;
/**
* Partition a DB result with backlinks in it into batches
- * @param $res ResultWrapper database result
- * @param $batchSize integer
- * @param $isComplete bool Whether $res includes all the backlinks
+ * @param ResultWrapper $res Database result
+ * @param int $batchSize
+ * @param bool $isComplete Whether $res includes all the backlinks
* @throws MWException
* @return array
*/
/**
* Create an instance.
- * @param $value Mixed: the user-supplied value
+ * @param mixed $value The user-supplied value
* @param CacheDependency|CacheDependency[] $deps A dependency or dependency
* array. All dependencies must be objects implementing CacheDependency.
*/
/**
* Get the user-defined value
- * @return bool|Mixed
+ * @return bool|mixed
*/
function getValue() {
return $this->value;
/**
* Store the wrapper to a cache
*
- * @param $cache BagOStuff
- * @param $key
- * @param $expiry
+ * @param BagOStuff $cache
+ * @param string $key
+ * @param int $expiry
*/
function storeToCache( $cache, $key, $expiry = 0 ) {
$this->initialiseDeps();
* it will be generated with the callback function (if present), and the newly
* calculated value will be stored to the cache in a wrapper.
*
- * @param $cache BagOStuff a cache object such as $wgMemc
- * @param string $key the cache key
- * @param $expiry Integer: the expiry timestamp or interval in seconds
- * @param $callback Mixed: the callback for generating the value, or false
- * @param array $callbackParams the function parameters for the callback
- * @param array $deps the dependencies to store on a cache miss. Note: these
+ * @param BagOStuff $cache A cache object such as $wgMemc
+ * @param string $key The cache key
+ * @param int $expiry The expiry timestamp or interval in seconds
+ * @param bool|array $callback The callback for generating the value, or false
+ * @param array $callbackParams The function parameters for the callback
+ * @param array $deps The dependencies to store on a cache miss. Note: these
* are not the dependencies used on a cache hit! Cache hits use the stored
* dependency array.
*
* Create a file dependency
*
* @param string $filename the name of the file, preferably fully qualified
- * @param $timestamp Mixed: the unix last modified timestamp, or false if the
+ * @param null|bool|int $timestamp The unix last modified timestamp, or false if the
* file does not exist. If omitted, the timestamp will be loaded from
* the file.
*
/**
* Save and compress text to the cache
* @param string $text
- * @return string compressed text
+ * @return string Compressed text
*/
public function saveText( $text ) {
global $wgUseFileCache;
/**
* Roughly increments the cache misses in the last hour by unique visitors
- * @param $request WebRequest
+ * @param WebRequest $request
* @return void
*/
public function incrMissesRecent( WebRequest $request ) {
/**
* Returns the default gender option in this wiki.
- * @return String
+ * @return string
*/
protected function getDefault() {
if ( $this->default === null ) {
/**
* Returns the gender for given username.
- * @param string $username or User: username
- * @param string $caller the calling method
- * @return String
+ * @param string|User $username Username
+ * @param string $caller The calling method
+ * @return string
*/
public function getGenderOf( $username, $caller = '' ) {
global $wgUser;
/**
* Wrapper for doQuery that processes raw LinkBatch data.
*
- * @param $data
- * @param $caller
+ * @param array $data
+ * @param string $caller
*/
public function doLinkBatch( $data, $caller = '' ) {
$users = array();
* Wrapper for doQuery that processes a title or string array.
*
* @since 1.20
- * @param $titles List: array of Title objects or strings
- * @param string $caller the calling method
+ * @param array $titles Array of Title objects or strings
+ * @param string $caller The calling method
*/
public function doTitlesArray( $titles, $caller = '' ) {
$users = array();
/**
* Preloads genders for given list of users.
- * @param $users List|String: usernames
- * @param string $caller the calling method
+ * @param array|string $users Usernames
+ * @param string $caller The calling method
*/
public function doQuery( $users, $caller = '' ) {
$default = $this->getDefault();
class HTMLFileCache extends FileCacheBase {
/**
* Construct an ObjectFileCache from a Title and an action
- * @param $title Title|string Title object or prefixed DB key string
- * @param $action string
+ * @param Title|string $title Title object or prefixed DB key string
+ * @param string $action
* @throws MWException
* @return HTMLFileCache
*/
/**
* Check if pages can be cached for this request/user
- * @param $context IContextSource
+ * @param IContextSource $context
* @return bool
*/
public static function useFileCache( IContextSource $context ) {
/**
* Read from cache to context output
- * @param $context IContextSource
+ * @param IContextSource $context
* @return void
*/
public function loadFromFileCache( IContextSource $context ) {
/**
* Save this cache object with the given text.
* Use this as an ob_start() handler.
- * @param $text string
+ * @param string $text
* @return bool Whether $wgUseFileCache is enabled
*/
public function saveToFileCache( $text ) {
/**
* Clear the file caches for a page for all actions
- * @param $title Title
+ * @param Title $title
* @return bool Whether $wgUseFileCache is enabled
*/
public static function clearFileCache( Title $title ) {
* class. Only used in debugging output.
* @since 1.17
*
- * @param $caller
+ * @param string $caller
*/
public function setCaller( $caller ) {
$this->caller = $caller;
}
/**
- * @param $title Title
+ * @param Title $title
*/
public function addObj( $title ) {
if ( is_object( $title ) ) {
}
/**
- * @param $ns int
- * @param $dbkey string
- * @return mixed
+ * @param int $ns
+ * @param string $dbkey
*/
public function add( $ns, $dbkey ) {
if ( $ns < 0 ) {
* Set the link list to a given 2-d array
* First key is the namespace, second is the DB key, value arbitrary
*
- * @param $array array
+ * @param array $array
*/
public function setArray( $array ) {
$this->data = $array;
/**
* Do the query and add the results to the LinkCache object
*
- * @return Array mapping PDBK to ID
+ * @return array Mapping PDBK to ID
*/
public function execute() {
$linkCache = LinkCache::singleton();
* Do the query and add the results to a given LinkCache object
* Return an array mapping PDBK to ID
*
- * @param $cache LinkCache
- * @return Array remaining IDs
+ * @param LinkCache $cache
+ * @return array Remaining IDs
*/
protected function executeInto( &$cache ) {
wfProfileIn( __METHOD__ );
* This function *also* stores extra fields of the title used for link
* parsing to avoid extra DB queries.
*
- * @param $cache LinkCache
- * @param $res
- * @return Array of remaining titles
+ * @param LinkCache $cache
+ * @param ResultWrapper $res
+ * @return array Array of remaining titles
*/
public function addResultToCache( $cache, $res ) {
if ( !$res ) {
/**
* Perform the existence test query, return a ResultWrapper with page_id fields
- * @return Bool|ResultWrapper
+ * @return bool|ResultWrapper
*/
public function doQuery() {
if ( $this->isEmpty() ) {
/**
* Do (and cache) {{GENDER:...}} information for userpages in this LinkBatch
*
- * @return bool whether the query was successful
+ * @return bool Whether the query was successful
*/
public function doGenderQuery() {
if ( $this->isEmpty() ) {
/**
* Construct a WHERE clause which will match all the given titles.
*
- * @param string $prefix the appropriate table's field name prefix ('page', 'pl', etc)
- * @param $db DatabaseBase object to use
- * @return mixed string with SQL where clause fragment, or false if no items.
+ * @param string $prefix The appropriate table's field name prefix ('page', 'pl', etc)
+ * @param DatabaseBase $db DatabaseBase object to use
+ * @return string|bool String with SQL where clause fragment, or false if no items.
*/
public function constructSet( $prefix, $db ) {
return $db->makeWhereFrom2d( $this->data, "{$prefix}_namespace", "{$prefix}_title" );
/**
* General accessor to get/set whether SELECT FOR UPDATE should be used
*
- * @param $update
+ * @param bool $update
* @return bool
*/
public function forUpdate( $update = null ) {
}
/**
- * @param $title
+ * @param string $title
* @return array|int
*/
public function getGoodLinkID( $title ) {
/**
* Get a field of a title object from cache.
* If this link is not good, it will return NULL.
- * @param $title Title
+ * @param Title $title
* @param string $field ('length','redirect','revision','model')
- * @return mixed
+ * @return string|null
*/
public function getGoodLinkFieldObj( $title, $field ) {
$dbkey = $title->getPrefixedDBkey();
}
/**
- * @param $title
+ * @param string $title
* @return bool
*/
public function isBadLink( $title ) {
/**
* Same as above with better interface.
* @since 1.19
- * @param $title Title
- * @param $row object which has the fields page_id, page_is_redirect,
+ * @param Title $title
+ * @param stdClass $row Object which has the fields page_id, page_is_redirect,
* page_latest and page_content_model
*/
public function addGoodLinkObjFromRow( $title, $row ) {
}
/**
- * @param $title Title
+ * @param Title $title
*/
public function addBadLinkObj( $title ) {
$dbkey = $title->getPrefixedDBkey();
}
/**
- * @param $title Title
+ * @param Title $title
*/
public function clearLink( $title ) {
$dbkey = $title->getPrefixedDBkey();
/**
* Add a title to the link cache, return the page_id or zero if non-existent
*
- * @param string $title title to add
- * @return Integer
+ * @param string $title Title to add
+ * @return int
*/
public function addLink( $title ) {
$nt = Title::newFromDBkey( $title );
/**
* Add a title to the link cache, return the page_id or zero if non-existent
*
- * @param $nt Title object to add
- * @return Integer
+ * @param Title $nt Title object to add
+ * @return int
*/
public function addLinkObj( $nt ) {
global $wgAntiLockFlags, $wgContentHandlerUseDB;
* For constructor parameters, see the documentation in DefaultSettings.php
* for $wgLocalisationCacheConf.
*
- * @param $conf Array
+ * @param array $conf
* @throws MWException
*/
function __construct( $conf ) {
/**
* Returns true if the given key is mergeable, that is, if it is an associative
* array which can be merged through a fallback sequence.
- * @param $key
+ * @param string $key
* @return bool
*/
public function isMergeableKey( $key ) {
*
* Warning: this may be slow for split items (messages), since it will
* need to fetch all of the subitems from the cache individually.
- * @param $code
- * @param $key
+ * @param string $code
+ * @param string $key
* @return mixed
*/
public function getItem( $code, $key ) {
/**
* Get a subitem, for instance a single message for a given language.
- * @param $code
- * @param $key
- * @param $subkey
- * @return null
+ * @param string $code
+ * @param string $key
+ * @param string $subkey
+ * @return mixed|null
*/
public function getSubitem( $code, $key, $subkey ) {
if ( !isset( $this->loadedSubitems[$code][$key][$subkey] ) &&
*
* Will return null if the item is not found, or false if the item is not an
* array.
- * @param $code
- * @param $key
+ * @param string $code
+ * @param string $key
* @return bool|null|string
*/
public function getSubitemList( $code, $key ) {
/**
* Load an item into the cache.
- * @param $code
- * @param $key
+ * @param string $code
+ * @param string $key
*/
protected function loadItem( $code, $key ) {
if ( !isset( $this->initialisedLangs[$code] ) ) {
/**
* Load a subitem into the cache
- * @param $code
- * @param $key
- * @param $subkey
+ * @param string $code
+ * @param string $key
+ * @param string $subkey
*/
protected function loadSubitem( $code, $key, $subkey ) {
if ( !in_array( $key, self::$splitKeys ) ) {
/**
* Initialise a language in this object. Rebuild the cache if necessary.
- * @param $code
+ * @param string $code
* @throws MWException
*/
protected function initLanguage( $code ) {
/**
* Create a fallback from one language to another, without creating a
* complete persistent cache.
- * @param $primaryCode
- * @param $fallbackCode
+ * @param string $primaryCode
+ * @param string $fallbackCode
*/
public function initShallowFallback( $primaryCode, $fallbackCode ) {
$this->data[$primaryCode] =& $this->data[$fallbackCode];
/**
* Read a PHP file containing localisation data.
- * @param $_fileName
- * @param $_fileType
+ * @param string $_fileName
+ * @param string $_fileType
* @throws MWException
* @return array
*/
* Read a JSON file containing localisation messages.
* @param string $fileName Name of file to read
* @throws MWException if there is a syntax error in the JSON file
- * @return array with a 'messages' key, or empty array if the file doesn't exist
+ * @return array Array with a 'messages' key, or empty array if the file doesn't exist
*/
public function readJSONFile( $fileName ) {
wfProfileIn( __METHOD__ );
/**
* Get the compiled plural rules for a given language from the XML files.
* @since 1.20
+ * @param string $code
+ * @return array|null
*/
public function getCompiledPluralRules( $code ) {
$rules = $this->getPluralRules( $code );
* Get the plural rules for a given language from the XML files.
* Cached.
* @since 1.20
+ * @param string $code
+ * @return array|null
*/
public function getPluralRules( $code ) {
if ( $this->pluralRules === null ) {
* Get the plural rule types for a given language from the XML files.
* Cached.
* @since 1.22
+ * @param string $code
+ * @return array|null
*/
public function getPluralRuleTypes( $code ) {
if ( $this->pluralRuleTypes === null ) {
/**
* Load a plural XML file with the given filename, compile the relevant
* rules, and save the compiled rules in a process-local cache.
+ *
+ * @param string $fileName
*/
protected function loadPluralFile( $fileName ) {
$doc = new DOMDocument;
* Read the data from the source files for a given language, and register
* the relevant dependencies in the $deps array. If the localisation
* exists, the data array is returned, otherwise false is returned.
+ *
+ * @param string $code
+ * @param array $deps
*/
protected function readSourceFilesAndRegisterDeps( $code, &$deps ) {
global $IP;
/**
* Merge two localisation values, a primary and a fallback, overwriting the
* primary value in place.
- * @param $key
- * @param $value
- * @param $fallbackValue
+ * @param string $key
+ * @param mixed $value
+ * @param mixed $fallbackValue
*/
protected function mergeItem( $key, &$value, $fallbackValue ) {
if ( !is_null( $value ) ) {
}
/**
- * @param $value
- * @param $fallbackValue
+ * @param mixed $value
+ * @param mixed $fallbackValue
*/
protected function mergeMagicWords( &$value, $fallbackValue ) {
foreach ( $fallbackValue as $magicName => $fallbackInfo ) {
*
* Returns true if any data from the extension array was used, false
* otherwise.
- * @param $codeSequence
- * @param $key
- * @param $value
- * @param $fallbackValue
+ * @param string $codeSequence
+ * @param string $key
+ * @param mixed $value
+ * @param mixed $fallbackValue
* @return bool
*/
protected function mergeExtensionItem( $codeSequence, $key, &$value, $fallbackValue ) {
/**
* Load localisation data for a given language for both core and extensions
* and save it to the persistent cache store and the process cache
- * @param $code
+ * @param string $code
* @throws MWException
*/
public function recache( $code ) {
*
* The preload item will be loaded automatically, improving performance
* for the commonly-requested items it contains.
- * @param $data
+ * @param array $data
* @return array
*/
protected function buildPreload( $data ) {
/**
* Unload the data for a given language from the object cache.
* Reduces memory usage.
- * @param $code
+ * @param string $code
*/
public function unload( $code ) {
unset( $this->data[$code] );
private $maxLoadedLangs = 10;
/**
- * @param $fileName
- * @param $fileType
+ * @param string $fileName
+ * @param string $fileType
* @return array|mixed
*/
protected function readPHPFile( $fileName, $fileType ) {
}
/**
- * @param $code
- * @param $key
+ * @param string $code
+ * @param string $key
* @return mixed
*/
public function getItem( $code, $key ) {
}
/**
- * @param $code
- * @param $key
- * @param $subkey
- * @return
+ * @param string $code
+ * @param string $key
+ * @param string $subkey
+ * @return mixed
*/
public function getSubitem( $code, $key, $subkey ) {
unset( $this->mruLangs[$code] );
}
/**
- * @param $code
+ * @param string $code
*/
public function recache( $code ) {
parent::recache( $code );
}
/**
- * @param $code
+ * @param string $code
*/
public function unload( $code ) {
unset( $this->mruLangs[$code] );
* @since 1.23
*/
class MapCacheLRU {
- /** @var Array */
+ /** @var array */
protected $cache = array(); // (key => value)
protected $maxCacheKeys; // integer; max entries
/**
- * @param $maxKeys integer Maximum number of entries allowed (min 1).
+ * @param int $maxKeys Maximum number of entries allowed (min 1).
* @throws MWException When $maxCacheKeys is not an int or =< 0.
*/
public function __construct( $maxKeys ) {
* This will prune the cache if it gets too large based on LRU.
* If the item is already set, it will be pushed to the top of the cache.
*
- * @param $key string
- * @param $value mixed
+ * @param string $key
+ * @param mixed $value
* @return void
*/
public function set( $key, $value ) {
/**
* Check if a key exists
*
- * @param $key string
+ * @param string $key
* @return bool
*/
public function has( $key ) {
* This returns null if the key is not set.
* If the item is already set, it will be pushed to the top of the cache.
*
- * @param $key string
+ * @param string $key
* @return mixed
*/
public function get( $key ) {
/**
* Clear one or several cache entries, or all cache entries
*
- * @param $keys string|Array
+ * @param string|array $keys
* @return void
*/
public function clear( $keys = null ) {
/**
* Push an entry to the top of the cache
*
- * @param $key string
+ * @param string $key
*/
protected function ping( $key ) {
$item = $this->cache[$key];
/**
* Try to load the cache from a local file.
*
- * @param string $hash the hash of contents, to check validity.
- * @param Mixed $code Optional language code, see documenation of load().
+ * @param string $hash The hash of contents, to check validity.
+ * @param string $code Optional language code, see documenation of load().
* @return array The cache array
*/
function getLocalCache( $hash, $code ) {
/**
* Save the cache to a local file.
+ * @param string $serialized
+ * @param string $hash
+ * @param string $code
*/
function saveToLocal( $serialized, $hash, $code ) {
global $wgCacheDirectory;
* or false if populating empty cache fails. Also returns true if MessageCache
* is disabled.
*
- * @param bool|String $code Language to which load messages
+ * @param bool|string $code Language to which load messages
* @throws MWException
* @return bool
*/
/**
* Is the given cache array expired due to time passing or a version change?
*
- * @param $cache
+ * @param array $cache
* @return bool
*/
protected function isCacheExpired( $cache ) {
* a timeout of MessageCache::MSG_LOCK_TIMEOUT.
*
* @param string $key
- * @return Boolean: success
+ * @return bool Success
*/
function lock( $key ) {
$lockKey = $key . ':lock';
* * Fallbacks will be just that: fallbacks. A fallback language will never be reached if
* the message is available *anywhere* in the language for which it is a fallback.
*
- * @param string $key the message key
+ * @param string $key The message key
* @param bool $useDB If true, look for the message in the DB, false
- * to use only the compiled l10n cache.
+ * to use only the compiled l10n cache.
* @param bool|string|object $langcode Code of the language to get the message for.
- * - If string and a valid code, will create a standard language object
- * - If string but not a valid code, will create a basic language object
- * - If boolean and false, create object from the current users language
- * - If boolean and true, create object from the wikis content language
- * - If language object, use it as given
- * @param bool $isFullKey specifies whether $key is a two part key
- * "msg/lang".
+ * - If string and a valid code, will create a standard language object
+ * - If string but not a valid code, will create a basic language object
+ * - If boolean and false, create object from the current users language
+ * - If boolean and true, create object from the wikis content language
+ * - If language object, use it as given
+ * @param bool $isFullKey specifies whether $key is a two part key "msg/lang".
*
* @throws MWException when given an invalid key
* @return string|bool False if the message doesn't exist, otherwise the
}
/**
- * @param $key
+ * @param string $key
* @return array
*/
public function figureMessage( $key ) {
* for which MediaWiki:msgkey exists. If $code is another language code, this
* will ONLY return message keys for which MediaWiki:msgkey/$code exists.
* @param string $code Language code
- * @return array of message keys (strings)
+ * @return array Array of message keys (strings)
*/
public function getAllMessageKeys( $code ) {
global $wgContLang;
class ObjectFileCache extends FileCacheBase {
/**
* Construct an ObjectFileCache from a key and a type
- * @param $key string
- * @param $type string
+ * @param string $key
+ * @param string $type
* @return ObjectFileCache
*/
public static function newFromKey( $key, $type ) {
/**
* Construct an ResourceFileCache from a context
- * @param $context ResourceLoaderContext
+ * @param ResourceLoaderContext $context
* @return ResourceFileCache
*/
public static function newFromContext( ResourceLoaderContext $context ) {
/**
* Check if an RL request can be cached.
* Caller is responsible for checking if any modules are private.
- * @param $context ResourceLoaderContext
+ * @param ResourceLoaderContext $context
* @return bool
*/
public static function useFileCache( ResourceLoaderContext $context ) {
/**
* Get a property of a user based on their user ID
*
- * @param $userId integer User ID
+ * @param int $userId User ID
* @param string $prop User property
- * @return mixed The property or false if the user does not exist
+ * @return mixed|bool The property or false if the user does not exist
*/
public function getProp( $userId, $prop ) {
if ( !isset( $this->cache[$userId][$prop] ) ) {
/**
* Get the name of a user or return $ip if the user ID is 0
*
- * @param integer $userId
+ * @param int $userId
* @param string $ip
* @return string
* @since 1.22
* Preloads user names for given list of users.
* @param array $userIds List of user IDs
* @param array $options Option flags; include 'userpage' and 'usertalk'
- * @param string $caller the calling method
+ * @param string $caller The calling method
*/
public function doQuery( array $userIds, $options = array(), $caller = '' ) {
wfProfileIn( __METHOD__ );
/**
* Check if a cache type is in $options and was not loaded for this user
*
- * @param $uid integer user ID
+ * @param int $uid User ID
* @param string $type Cache type
* @param array $options Requested cache types
* @return bool
*/
class APCBagOStuff extends BagOStuff {
/**
- * @param $key string
- * @param $casToken[optional] int
+ * @param string $key
+ * @param int $casToken [optional]
* @return mixed
*/
public function get( $key, &$casToken = null ) {
}
/**
- * @param $key string
- * @param $value mixed
- * @param $exptime int
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function set( $key, $value, $exptime = 0 ) {
}
/**
- * @param $casToken mixed
- * @param $key string
- * @param $value mixed
- * @param $exptime int
+ * @param mixed $casToken
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function cas( $casToken, $key, $value, $exptime = 0 ) {
}
/**
- * @param $key string
- * @param $time int
+ * @param string $key
+ * @param int $time
* @return bool
*/
public function delete( $key, $time = 0 ) {
}
/**
- * @param $key string
- * @param $callback closure Callback method to be executed
+ * @param string $key
+ * @param closure $callback Callback method to be executed
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
- * @return bool success
+ * @return bool Success
*/
public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) {
return $this->mergeViaLock( $key, $callback, $exptime, $attempts );
const ERR_UNEXPECTED = 3; // response gave some error
/**
- * @param $bool bool
+ * @param bool $bool
*/
public function setDebug( $bool ) {
$this->debugMode = $bool;
/**
* Get an item with the given key. Returns false if it does not exist.
- * @param $key string
- * @param $casToken[optional] mixed
+ * @param string $key
+ * @param mixed $casToken [optional]
* @return mixed Returns false on failure
*/
abstract public function get( $key, &$casToken = null );
/**
* Set an item.
- * @param $key string
- * @param $value mixed
+ * @param string $key
+ * @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
- * @return bool success
+ * @return bool Success
*/
abstract public function set( $key, $value, $exptime = 0 );
/**
* Check and set an item.
- * @param $casToken mixed
- * @param $key string
- * @param $value mixed
+ * @param mixed $casToken
+ * @param string $key
+ * @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
- * @return bool success
+ * @return bool Success
*/
abstract public function cas( $casToken, $key, $value, $exptime = 0 );
/**
* Delete an item.
- * @param $key string
+ * @param string $key
* @param int $time Amount of time to delay the operation (mostly memcached-specific)
* @return bool True if the item was deleted or not found, false on failure
*/
* The callback function returns the new value given the current value (possibly false),
* and takes the arguments: (this BagOStuff object, cache key, current value).
*
- * @param $key string
- * @param $callback closure Callback method to be executed
+ * @param string $key
+ * @param closure $callback Callback method to be executed
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
- * @return bool success
+ * @return bool Success
*/
public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) {
return $this->mergeViaCas( $key, $callback, $exptime, $attempts );
/**
* @see BagOStuff::merge()
*
- * @param $key string
- * @param $callback closure Callback method to be executed
+ * @param string $key
+ * @param closure $callback Callback method to be executed
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
- * @return bool success
+ * @return bool Success
*/
protected function mergeViaCas( $key, closure $callback, $exptime = 0, $attempts = 10 ) {
do {
/**
* @see BagOStuff::merge()
*
- * @param $key string
- * @param $callback closure Callback method to be executed
+ * @param string $key
+ * @param closure $callback Callback method to be executed
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
- * @return bool success
+ * @return bool Success
*/
protected function mergeViaLock( $key, closure $callback, $exptime = 0, $attempts = 10 ) {
if ( !$this->lock( $key, 6 ) ) {
}
/**
- * @param $key string
- * @param $timeout integer [optional]
- * @return bool success
+ * @param string $key
+ * @param int $timeout [optional]
+ * @return bool Success
*/
public function lock( $key, $timeout = 6 ) {
$this->clearLastError();
}
/**
- * @param $key string
- * @return bool success
+ * @param string $key
+ * @return bool Success
*/
public function unlock( $key ) {
return $this->delete( "{$key}:lock" );
/**
* Delete all objects expiring before a certain date.
* @param string $date The reference date in MW format
- * @param $progressCallback callback|bool Optional, a function which will be called
+ * @param callback|bool $progressCallback Optional, a function which will be called
* regularly during long-running operations with the percentage progress
* as the first parameter.
*
- * @return bool on success, false if unimplemented
+ * @return bool Success, false if unimplemented
*/
public function deleteObjectsExpiringBefore( $date, $progressCallback = false ) {
// stub
/**
* Get an associative array containing the item for each of the keys that have items.
* @param array $keys List of strings
- * @return Array
+ * @return array
*/
public function getMulti( array $keys ) {
$res = array();
}
/**
- * @param $key string
- * @param $value mixed
- * @param $exptime integer
- * @return bool success
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
+ * @return bool Success
*/
public function add( $key, $value, $exptime = 0 ) {
if ( $this->get( $key ) === false ) {
}
/**
- * @param $key string
- * @param $value mixed
- * @param $exptime int
- * @return bool success
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
+ * @return bool Success
* @deprecated since 1.23
*/
public function replace( $key, $value, $exptime = 0 ) {
/**
* Increase stored value of $key by $value while preserving its TTL
* @param string $key Key to increase
- * @param $value Integer: Value to add to $key (Default 1)
- * @return integer|bool New value or false on failure
+ * @param int $value Value to add to $key (Default 1)
+ * @return int|bool New value or false on failure
*/
public function incr( $key, $value = 1 ) {
if ( !$this->lock( $key ) ) {
/**
* Decrease stored value of $key by $value while preserving its TTL
- * @param $key String
- * @param $value Integer
- * @return integer
+ * @param string $key
+ * @param int $value
+ * @return int
*/
public function decr( $key, $value = 1 ) {
return $this->incr( $key, - $value );
/**
* Get the "last error" registered; clearLastError() should be called manually
- * @return integer ERR_* constant for the "last error" registry
+ * @return int ERR_* constant for the "last error" registry
* @since 1.23
*/
public function getLastError() {
/**
* Set the "last error" registry
- * @param $err integer ERR_* constant
+ * @param int $err ERR_* constant
* @since 1.23
*/
protected function setLastError( $err ) {
}
/**
- * @param $text string
+ * @param string $text
*/
public function debug( $text ) {
if ( $this->debugMode ) {
/**
* Convert an optionally relative time to an absolute time
- * @param $exptime integer
+ * @param int $exptime
* @return int
*/
protected function convertExpiry( $exptime ) {
* Convert an optionally absolute expiry time to a relative time. If an
* absolute time is specified which is in the past, use a short expiry time.
*
- * @param $exptime integer
- * @return integer
+ * @param int $exptime
+ * @return int
*/
protected function convertToRelative( $exptime ) {
if ( $exptime >= 86400 * 3650 /* 10 years */ ) {
/**
* Check if a value is an integer
*
- * @param $value mixed
+ * @param mixed $value
* @return bool
*/
protected function isInteger( $value ) {
class EmptyBagOStuff extends BagOStuff {
/**
- * @param $key string
- * @param $casToken[optional] mixed
+ * @param string $key
+ * @param mixed $casToken [optional]
* @return bool
*/
function get( $key, &$casToken = null ) {
}
/**
- * @param $key string
- * @param $value mixed
- * @param $exp int
+ * @param string $key
+ * @param mixed $value
+ * @param int $exp
* @return bool
*/
function set( $key, $value, $exp = 0 ) {
}
/**
- * @param $casToken mixed
- * @param $key string
- * @param $value mixed
- * @param $exp int
+ * @param mixed $casToken
+ * @param string $key
+ * @param mixed $value
+ * @param int $exp
* @return bool
*/
function cas( $casToken, $key, $value, $exp = 0 ) {
}
/**
- * @param $key string
- * @param $time int
+ * @param string $key
+ * @param int $time
* @return bool
*/
function delete( $key, $time = 0 ) {
}
/**
- * @param $key string
- * @param $callback closure Callback method to be executed
+ * @param string $key
+ * @param closure $callback Callback method to be executed
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
- * @return bool success
+ * @return bool Success
*/
public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) {
return true;
}
/**
- * @param $key string
+ * @param string $key
* @return bool
*/
protected function expire( $key ) {
}
/**
- * @param $key string
- * @param $casToken[optional] mixed
+ * @param string $key
+ * @param mixed $casToken [optional]
* @return bool|mixed
*/
function get( $key, &$casToken = null ) {
}
/**
- * @param $key string
- * @param $value mixed
- * @param $exptime int
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
function set( $key, $value, $exptime = 0 ) {
}
/**
- * @param $casToken mixed
- * @param $key string
- * @param $value mixed
- * @param $exptime int
+ * @param mixed $casToken
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
function cas( $casToken, $key, $value, $exptime = 0 ) {
}
/**
- * @param $key string
- * @param $time int
+ * @param string $key
+ * @param int $time
* @return bool
*/
function delete( $key, $time = 0 ) {
/**
* Fill in the defaults for any parameters missing from $params, using the
* backwards-compatible global variables
+ * @param array $params
+ * @return array
*/
protected function applyDefaultParams( $params ) {
if ( !isset( $params['servers'] ) ) {
}
/**
- * @param $key string
- * @param $casToken[optional] mixed
- * @return Mixed
+ * @param string $key
+ * @param mixed $casToken [optional]
+ * @return mixed
*/
public function get( $key, &$casToken = null ) {
return $this->client->get( $this->encodeKey( $key ), $casToken );
}
/**
- * @param $key string
- * @param $value
- * @param $exptime int
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function set( $key, $value, $exptime = 0 ) {
}
/**
- * @param $key string
- * @param $casToken mixed
- * @param $value
- * @param $exptime int
+ * @param string $key
+ * @param mixed $casToken
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function cas( $casToken, $key, $value, $exptime = 0 ) {
}
/**
- * @param $key string
- * @param $time int
+ * @param string $key
+ * @param int $time
* @return bool
*/
public function delete( $key, $time = 0 ) {
}
/**
- * @param $key string
- * @param $value int
+ * @param string $key
+ * @param int $value
* @param int $exptime (default 0)
- * @return Mixed
+ * @return mixed
*/
public function add( $key, $value, $exptime = 0 ) {
return $this->client->add( $this->encodeKey( $key ), $value,
/**
* Get the underlying client object. This is provided for debugging
* purposes.
+ * @return BagOStuff
*/
public function getClient() {
return $this->client;
* the other control characters for compatibility with libmemcached
* verify_key. We leave other punctuation alone, to maximise backwards
* compatibility.
- * @param $key string
+ * @param string $key
* @return string
*/
public function encodeKey( $key ) {
}
/**
- * @param $m array
+ * @param array $m
* @return string
*/
protected function encodeKeyCallback( $m ) {
* discarded immediately because the expiry is in the past.
* Clamp expiries >30d at 30d, unless they're >=1e9 in which
* case they are likely to really be absolute (1e9 = 2011-09-09)
+ * @param int $expiry
+ * @return int
*/
function fixExpiry( $expiry ) {
if ( $expiry > 2592000 && $expiry < 1000000000 ) {
* Decode a key encoded with encodeKey(). This is provided as a convenience
* function for debugging.
*
- * @param $key string
+ * @param string $key
*
* @return string
*/
/**
* Send a debug message to the log
+ * @param string $text
*/
protected function debugLog( $text ) {
wfDebugLog( 'memcached', $text );
/**
* Current debug status; 0 - none to 9 - profiling
*
- * @var boolean
+ * @var bool
* @access private
*/
var $_debug;
/**
* Is compression available?
*
- * @var boolean
+ * @var bool
* @access private
*/
var $_have_zlib;
/**
* Do we want to use compression?
*
- * @var boolean
+ * @var bool
* @access private
*/
var $_compress_enable;
/**
* At how many bytes should we compress?
*
- * @var integer
+ * @var int
* @access private
*/
var $_compress_threshold;
/**
* Are we using persistent links?
*
- * @var boolean
+ * @var bool
* @access private
*/
var $_persistent;
/**
* Total # of bit buckets we have
*
- * @var integer
+ * @var int
* @access private
*/
var $_bucketcount;
/**
* # of total servers we have
*
- * @var integer
+ * @var int
* @access private
*/
var $_active;
/**
* Stream timeout in seconds. Applies for example to fread()
*
- * @var integer
+ * @var int
* @access private
*/
var $_timeout_seconds;
/**
* Stream timeout in microseconds
*
- * @var integer
+ * @var int
* @access private
*/
var $_timeout_microseconds;
* Adds a key/value to the memcache server if one isn't already set with
* that key
*
- * @param string $key key to set with data
- * @param $val Mixed: value to store
- * @param $exp Integer: (optional) Expiration time. This can be a number of seconds
+ * @param string $key Key to set with data
+ * @param mixed $val Value to store
+ * @param int $exp (optional) Expiration time. This can be a number of seconds
* to cache for (up to 30 days inclusive). Any timespans of 30 days + 1 second or
* longer must be the timestamp of the time at which the mapping should expire. It
* is safe to use timestamps in all cases, regardless of expiration
* eg: strtotime("+3 hour")
*
- * @return Boolean
+ * @return bool
*/
public function add( $key, $val, $exp = 0 ) {
return $this->_set( 'add', $key, $val, $exp );
/**
* Decrease a value stored on the memcache server
*
- * @param string $key key to decrease
- * @param $amt Integer: (optional) amount to decrease
+ * @param string $key Key to decrease
+ * @param int $amt (optional) amount to decrease
*
- * @return Mixed: FALSE on failure, value on success
+ * @return mixed False on failure, value on success
*/
public function decr( $key, $amt = 1 ) {
return $this->_incrdecr( 'decr', $key, $amt );
/**
* Deletes a key from the server, optionally after $time
*
- * @param string $key key to delete
- * @param $time Integer: (optional) how long to wait before deleting
+ * @param string $key Key to delete
+ * @param int $time (optional) how long to wait before deleting
*
- * @return Boolean: TRUE on success, FALSE on failure
+ * @return bool True on success, false on failure
*/
public function delete( $key, $time = 0 ) {
if ( !$this->_active ) {
}
/**
- * @param $key
- * @param $timeout int
+ * @param string $key
+ * @param int $timeout
* @return bool
*/
public function lock( $key, $timeout = 0 ) {
}
/**
- * @param $key
+ * @param string $key
* @return bool
*/
public function unlock( $key ) {
/**
* Enable / Disable compression
*
- * @param $enable Boolean: TRUE to enable, FALSE to disable
+ * @param bool $enable True to enable, false to disable
*/
public function enable_compress( $enable ) {
$this->_compress_enable = $enable;
* Retrieves the value associated with the key from the memcache server
*
* @param array|string $key key to retrieve
- * @param $casToken[optional] Float
+ * @param float $casToken [optional]
*
- * @return Mixed
+ * @return mixed
*/
public function get( $key, &$casToken = null ) {
wfProfileIn( __METHOD__ );
/**
* Get multiple keys from the server(s)
*
- * @param array $keys keys to retrieve
+ * @param array $keys Keys to retrieve
*
- * @return Array
+ * @return array
*/
public function get_multi( $keys ) {
if ( !$this->_active ) {
/**
* Increments $key (optionally) by $amt
*
- * @param string $key key to increment
- * @param $amt Integer: (optional) amount to increment
+ * @param string $key Key to increment
+ * @param int $amt (optional) amount to increment
*
- * @return Integer: null if the key does not exist yet (this does NOT
+ * @return int|null Null if the key does not exist yet (this does NOT
* create new mappings if the key does not exist). If the key does
* exist, this returns the new value for that key.
*/
/**
* Overwrites an existing value for key; only works if key is already set
*
- * @param string $key key to set value as
- * @param $value Mixed: value to store
- * @param $exp Integer: (optional) Expiration time. This can be a number of seconds
+ * @param string $key Key to set value as
+ * @param mixed $value Value to store
+ * @param int $exp (optional) Expiration time. This can be a number of seconds
* to cache for (up to 30 days inclusive). Any timespans of 30 days + 1 second or
* longer must be the timestamp of the time at which the mapping should expire. It
* is safe to use timestamps in all cases, regardless of exipration
* eg: strtotime("+3 hour")
*
- * @return Boolean
+ * @return bool
*/
public function replace( $key, $value, $exp = 0 ) {
return $this->_set( 'replace', $key, $value, $exp );
* Passes through $cmd to the memcache server connected by $sock; returns
* output as an array (null array if no output)
*
- * @param $sock Resource: socket to send command on
- * @param string $cmd command to run
+ * @param Resource $sock Socket to send command on
+ * @param string $cmd Command to run
*
- * @return Array: output array
+ * @return array Output array
*/
public function run_command( $sock, $cmd ) {
if ( !is_resource( $sock ) ) {
* Unconditionally sets a key to a given value in the memcache. Returns true
* if set successfully.
*
- * @param string $key key to set value as
- * @param $value Mixed: value to set
- * @param $exp Integer: (optional) Expiration time. This can be a number of seconds
+ * @param string $key Key to set value as
+ * @param mixed $value Value to set
+ * @param int $exp (optional) Expiration time. This can be a number of seconds
* to cache for (up to 30 days inclusive). Any timespans of 30 days + 1 second or
* longer must be the timestamp of the time at which the mapping should expire. It
* is safe to use timestamps in all cases, regardless of exipration
* eg: strtotime("+3 hour")
*
- * @return Boolean: TRUE on success
+ * @return bool True on success
*/
public function set( $key, $value, $exp = 0 ) {
return $this->_set( 'set', $key, $value, $exp );
* Sets a key to a given value in the memcache if the current value still corresponds
* to a known, given value. Returns true if set successfully.
*
- * @param $casToken Float: current known value
- * @param string $key key to set value as
- * @param $value Mixed: value to set
- * @param $exp Integer: (optional) Expiration time. This can be a number of seconds
+ * @param float $casToken Current known value
+ * @param string $key Key to set value as
+ * @param mixed $value Value to set
+ * @param int $exp (optional) Expiration time. This can be a number of seconds
* to cache for (up to 30 days inclusive). Any timespans of 30 days + 1 second or
* longer must be the timestamp of the time at which the mapping should expire. It
* is safe to use timestamps in all cases, regardless of exipration
* eg: strtotime("+3 hour")
*
- * @return Boolean: TRUE on success
+ * @return bool True on success
*/
public function cas( $casToken, $key, $value, $exp = 0 ) {
return $this->_set( 'cas', $key, $value, $exp, $casToken );
/**
* Sets the compression threshold
*
- * @param $thresh Integer: threshold to compress if larger than
+ * @param int $thresh Threshold to compress if larger than
*/
public function set_compress_threshold( $thresh ) {
$this->_compress_threshold = $thresh;
/**
* Sets the debug flag
*
- * @param $dbg Boolean: TRUE for debugging, FALSE otherwise
+ * @param bool $dbg True for debugging, false otherwise
*
- * @see MWMemcached::__construct
+ * @see MWMemcached::__construct
*/
public function set_debug( $dbg ) {
$this->_debug = $dbg;
/**
* Sets the server list to distribute key gets and puts between
*
- * @param array $list of servers to connect to
+ * @param array $list Array of servers to connect to
*
- * @see MWMemcached::__construct()
+ * @see MWMemcached::__construct()
*/
public function set_servers( $list ) {
$this->_servers = $list;
/**
* Sets the timeout for new connections
*
- * @param $seconds Integer: number of seconds
- * @param $microseconds Integer: number of microseconds
+ * @param int $seconds Number of seconds
+ * @param int $microseconds Number of microseconds
*/
public function set_timeout( $seconds, $microseconds ) {
$this->_timeout_seconds = $seconds;
/**
* Close the specified socket
*
- * @param string $sock socket to close
+ * @param string $sock Socket to close
*
* @access private
*/
/**
* Connects $sock to $host, timing out after $timeout
*
- * @param $sock Integer: socket to connect
+ * @param int $sock Socket to connect
* @param string $host Host:IP to connect to
*
- * @return boolean
+ * @return bool
* @access private
*/
function _connect_sock( &$sock, $host ) {
/**
* Marks a host as dead until 30-40 seconds in the future
*
- * @param string $sock socket to mark as dead
+ * @param string $sock Socket to mark as dead
*
* @access private
*/
}
/**
- * @param $host
+ * @param string $host
*/
function _dead_host( $host ) {
$parts = explode( ':', $host );
/**
* get_sock
*
- * @param string $key key to retrieve value for;
+ * @param string $key Key to retrieve value for;
*
- * @return Mixed: resource on success, false on failure
+ * @return Resource|bool Resource on success, false on failure
* @access private
*/
function get_sock( $key ) {
/**
* Creates a hash integer based on the $key
*
- * @param string $key key to hash
+ * @param string $key Key to hash
*
- * @return Integer: hash value
+ * @return int Hash value
* @access private
*/
function _hashfunc( $key ) {
/**
* Perform increment/decriment on $key
*
- * @param string $cmd command to perform
- * @param string|array $key key to perform it on
- * @param $amt Integer amount to adjust
+ * @param string $cmd Command to perform
+ * @param string|array $key Key to perform it on
+ * @param int $amt Amount to adjust
*
- * @return Integer: new value of $key
+ * @return int New value of $key
* @access private
*/
function _incrdecr( $cmd, $key, $amt = 1 ) {
/**
* Load items into $ret from $sock
*
- * @param $sock Resource: socket to read from
+ * @param Resource $sock Socket to read from
* @param array $ret returned values
- * @param $casToken[optional] Float
- * @return boolean True for success, false for failure
+ * @param float $casToken [optional]
+ * @return bool True for success, false for failure
*
* @access private
*/
/**
* Performs the requested storage operation to the memcache server
*
- * @param string $cmd command to perform
- * @param string $key key to act on
- * @param $val Mixed: what we need to store
- * @param $exp Integer: (optional) Expiration time. This can be a number of seconds
+ * @param string $cmd Command to perform
+ * @param string $key Key to act on
+ * @param mixed $val What we need to store
+ * @param int $exp (optional) Expiration time. This can be a number of seconds
* to cache for (up to 30 days inclusive). Any timespans of 30 days + 1 second or
* longer must be the timestamp of the time at which the mapping should expire. It
* is safe to use timestamps in all cases, regardless of exipration
* eg: strtotime("+3 hour")
- * @param $casToken[optional] Float
+ * @param float $casToken [optional]
*
- * @return Boolean
+ * @return bool
* @access private
*/
function _set( $cmd, $key, $val, $exp, $casToken = null ) {
*
* @param string $host Host:IP to get socket for
*
- * @return Mixed: IO Stream or false
+ * @return Resource|bool IO Stream or false
* @access private
*/
function sock_to_host( $host ) {
}
/**
- * @param $text string
+ * @param string $text
*/
function _debugprint( $text ) {
wfDebugLog( 'memcached', $text );
}
/**
- * @param $text string
+ * @param string $text
*/
function _error_log( $text ) {
wfDebugLog( 'memcached-serious', "Memcached error: $text" );
/**
* Write to a stream. If there is an error, mark the socket dead.
*
- * @param $sock The socket
- * @param $buf The string to write
+ * @param Resource $sock The socket
+ * @param string $buf The string to write
* @return bool True on success, false on failure
*/
function _fwrite( $sock, $buf ) {
/**
* Handle an I/O error. Mark the socket dead and log an error.
+ *
+ * @param Resource $sock
+ * @param string $msg
*/
function _handle_error( $sock, $msg ) {
$peer = stream_socket_get_name( $sock, true /** remote **/ );
* Read the specified number of bytes from a stream. If there is an error,
* mark the socket dead.
*
- * @param $sock The socket
- * @param $len The number of bytes to read
- * @return The string on success, false on failure.
+ * @param Resource $sock The socket
+ * @param int $len The number of bytes to read
+ * @return string|bool The string on success, false on failure.
*/
function _fread( $sock, $len ) {
$buf = '';
* Read a line from a stream. If there is an error, mark the socket dead.
* The \r\n line ending is stripped from the response.
*
- * @param $sock The socket
- * @return The string on success, false on failure
+ * @param Resource $sock The socket
+ * @return string|bool The string on success, false on failure
*/
function _fgets( $sock ) {
$result = fgets( $sock );
/**
* Flush the read buffer of a stream
- * @param $f Resource
+ * @param Resource $f
*/
function _flush_read_buffer( $f ) {
if ( !is_resource( $f ) ) {
* - serializer: May be either "php" or "igbinary". Igbinary produces more compact
* values, but serialization is much slower unless the php.ini option
* igbinary.compact_strings is off.
+ * @param array $params
*/
function __construct( $params ) {
$params = $this->applyDefaultParams( $params );
}
/**
- * @param $key string
- * @param $casToken[optional] float
- * @return Mixed
+ * @param string $key
+ * @param float $casToken [optional]
+ * @return mixed
*/
public function get( $key, &$casToken = null ) {
wfProfileIn( __METHOD__ );
}
/**
- * @param $key string
- * @param $value
- * @param $exptime int
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function set( $key, $value, $exptime = 0 ) {
}
/**
- * @param $casToken float
- * @param $key string
- * @param $value
- * @param $exptime int
+ * @param float $casToken
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function cas( $casToken, $key, $value, $exptime = 0 ) {
}
/**
- * @param $key string
- * @param $time int
+ * @param string $key
+ * @param int $time
* @return bool
*/
public function delete( $key, $time = 0 ) {
}
/**
- * @param $key string
- * @param $value int
- * @param $exptime int
- * @return Mixed
+ * @param string $key
+ * @param int $value
+ * @param int $exptime
+ * @return mixed
*/
public function add( $key, $value, $exptime = 0 ) {
$this->debugLog( "add($key)" );
}
/**
- * @param $key string
- * @param $value int
- * @return Mixed
+ * @param string $key
+ * @param int $value
+ * @return mixed
*/
public function incr( $key, $value = 1 ) {
$this->debugLog( "incr($key)" );
}
/**
- * @param $key string
- * @param $value int
- * @return Mixed
+ * @param string $key
+ * @param int $value
+ * @return mixed
*/
public function decr( $key, $value = 1 ) {
$this->debugLog( "decr($key)" );
* different.
*
* @param string $key The key used by the caller, or false if there wasn't one.
- * @param $result Mixed The return value
- * @return Mixed
+ * @param mixed $result The return value
+ * @return mixed
*/
protected function checkResult( $key, $result ) {
if ( $result !== false ) {
}
/**
- * @param $keys Array
- * @return Array
+ * @param array $keys
+ * @return array
*/
public function getMulti( array $keys ) {
wfProfileIn( __METHOD__ );
* - timeout: The read timeout in microseconds
* - connect_timeout: The connect timeout in seconds
*
- * @param $params array
+ * @param array $params
*/
function __construct( $params ) {
$params = $this->applyDefaultParams( $params );
}
/**
- * @param $debug bool
+ * @param bool $debug
*/
public function setDebug( $debug ) {
$this->client->set_debug( $debug );
}
/**
- * @param $keys Array
- * @return Array
+ * @param array $keys
+ * @return array
*/
public function getMulti( array $keys ) {
$callback = array( $this, 'encodeKey' );
}
/**
- * @param $key
- * @param $timeout int
+ * @param string $key
+ * @param int $timeout
* @return bool
*/
public function lock( $key, $timeout = 0 ) {
}
/**
- * @param $key string
- * @return Mixed
+ * @param string $key
+ * @return mixed
*/
public function unlock( $key ) {
return $this->client->unlock( $this->encodeKey( $key ) );
}
/**
- * @param $key string
- * @param $value int
- * @return Mixed
+ * @param string $key
+ * @param int $value
+ * @return mixed
*/
public function incr( $key, $value = 1 ) {
return $this->client->incr( $this->encodeKey( $key ), $value );
}
/**
- * @param $key string
- * @param $value int
- * @return Mixed
+ * @param string $key
+ * @param int $value
+ * @return mixed
*/
public function decr( $key, $value = 1 ) {
return $this->client->decr( $this->encodeKey( $key ), $value );
* structures, in the style required by $wgObjectCaches. See
* the documentation of $wgObjectCaches for more detail.
*
- * @param $params array
+ * @param array $params
* @throws MWException
*/
public function __construct( $params ) {
}
/**
- * @param $debug bool
+ * @param bool $debug
*/
public function setDebug( $debug ) {
$this->doWrite( 'setDebug', $debug );
}
/**
- * @param $key string
- * @param $casToken[optional] mixed
+ * @param string $key
+ * @param mixed $casToken [optional]
* @return bool|mixed
*/
public function get( $key, &$casToken = null ) {
}
/**
- * @param $casToken mixed
- * @param $key string
- * @param $value mixed
- * @param $exptime int
+ * @param mixed $casToken
+ * @param string $key
+ * @param mixed $value
+ * @param mixed $exptime
* @return bool
*/
public function cas( $casToken, $key, $value, $exptime = 0 ) {
}
/**
- * @param $key string
- * @param $value mixed
- * @param $exptime int
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function set( $key, $value, $exptime = 0 ) {
}
/**
- * @param $key string
- * @param $time int
+ * @param string $key
+ * @param int $time
* @return bool
*/
public function delete( $key, $time = 0 ) {
}
/**
- * @param $key string
- * @param $value mixed
- * @param $exptime int
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function add( $key, $value, $exptime = 0 ) {
}
/**
- * @param $key string
- * @param $value mixed
- * @param $exptime int
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function replace( $key, $value, $exptime = 0 ) {
}
/**
- * @param $key string
- * @param $value int
+ * @param string $key
+ * @param int $value
* @return bool|null
*/
public function incr( $key, $value = 1 ) {
}
/**
- * @param $key string
- * @param $value int
+ * @param string $key
+ * @param int $value
* @return bool
*/
public function decr( $key, $value = 1 ) {
}
/**
- * @param $key string
- * @param $timeout int
+ * @param string $key
+ * @param int $timeout
* @return bool
*/
public function lock( $key, $timeout = 0 ) {
}
/**
- * @param $key string
+ * @param string $key
* @return bool
*/
public function unlock( $key ) {
}
/**
- * @param $key string
- * @param $callback closure Callback method to be executed
+ * @param string $key
+ * @param closure $callback Callback method to be executed
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
- * @return bool success
+ * @return bool Success
*/
public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) {
return $this->doWrite( 'merge', $key, $callback, $exptime );
}
/**
- * @param $method string
+ * @param string $method
* @return bool
*/
protected function doWrite( $method /*, ... */ ) {
* Delete objects expiring before a certain date.
*
* Succeed if any of the child caches succeed.
- * @param $date string
- * @param $progressCallback bool|callback
+ * @param string $date
+ * @param bool|callback $progressCallback
* @return bool
*/
public function deleteObjectsExpiringBefore( $date, $progressCallback = false ) {
/**
* Get a cached instance of the specified type of cache object.
*
- * @param $id string
+ * @param string $id
*
* @return BagOStuff
*/
/**
* Create a new cache object of the specified type.
*
- * @param $id string
+ * @param string $id
*
* @throws MWException
* @return BagOStuff
/**
* Create a new cache object from parameters
*
- * @param $params array
+ * @param array $params
*
* @throws MWException
* @return BagOStuff
* be an alias to the configured cache choice for that.
* If no cache choice is configured (by default $wgMainCacheType is CACHE_NONE),
* then CACHE_ANYTHING will forward to CACHE_DB.
- * @param $params array
+ * @param array $params
* @return BagOStuff
*/
static function newAnything( $params ) {
/**
* Factory function referenced from DefaultSettings.php for CACHE_ACCEL.
*
- * @param $params array
+ * @param array $params
* @throws MWException
* @return BagOStuff
*/
* hashing scheme and a different interpretation of the flags bitfield, so
* switching between the two clients randomly would be disastrous.
*
- * @param $params array
+ * @param array $params
*
* @return MemcachedPhpBagOStuff
*/
/**
* Get the cache storage object to use for session storage
+ * @return ObjectCache
*/
static function getCache() {
global $wgSessionCacheType;
/**
* Get a cache key for the given session id.
*
- * @param string $id session id
- * @return String: cache key
+ * @param string $id Session id
+ * @return string Cache key
*/
static function getKey( $id ) {
return wfMemcKey( 'session', $id );
/**
* Callback when opening a session.
*
- * @param $save_path String: path used to store session files, unused
- * @param $session_name String: session name
- * @return Boolean: success
+ * @param string $save_path Path used to store session files, unused
+ * @param string $session_name Session name
+ * @return bool Success
*/
static function open( $save_path, $session_name ) {
return true;
* Callback when closing a session.
* NOP.
*
- * @return Boolean: success
+ * @return bool Success
*/
static function close() {
return true;
/**
* Callback when reading session data.
*
- * @param string $id session id
- * @return Mixed: session data
+ * @param string $id Session id
+ * @return mixed Session data
*/
static function read( $id ) {
$data = self::getCache()->get( self::getKey( $id ) );
/**
* Callback when writing session data.
*
- * @param string $id session id
- * @param $data Mixed: session data
- * @return Boolean: success
+ * @param string $id Session id
+ * @param mixed $data Session data
+ * @return bool Success
*/
static function write( $id, $data ) {
global $wgObjectCacheSessionExpiry;
/**
* Callback to destroy a session when calling session_destroy().
*
- * @param string $id session id
- * @return Boolean: success
+ * @param string $id Session id
+ * @return bool Success
*/
static function destroy( $id ) {
self::getCache()->delete( self::getKey( $id ) );
* Callback to execute garbage collection.
* NOP: Object caches perform garbage collection implicitly
*
- * @param $maxlifetime Integer: maximum session life time
- * @return Boolean: success
+ * @param int $maxlifetime Maximum session life time
+ * @return bool Success
*/
static function gc( $maxlifetime ) {
return true;
class RedisBagOStuff extends BagOStuff {
/** @var RedisConnectionPool */
protected $redisPool;
- /** @var Array List of server names */
+ /** @var array List of server names */
protected $servers;
/** @var bool */
protected $automaticFailover;
* consistent hashing algorithm). True by default. This has the
* potential to create consistency issues if a server is slow enough to
* flap, for example if it is in swap death.
+ * @param array $params
*/
function __construct( $params ) {
$redisConf = array( 'serializer' => 'none' ); // manage that in this class
* command. But we are constrained by the memcached-like interface to
* return null in that case. Once the key exists, further increments are
* atomic.
+ * @param string $key
+ * @param int $value
+ * @param bool|mixed
*/
public function incr( $key, $value = 1 ) {
$section = new ProfileSection( __METHOD__ );
/**
* Get a Redis object with a connection suitable for fetching the specified key
- * @return Array (server, RedisConnRef) or (false, false)
+ * @return array (server, RedisConnRef) or (false, false)
*/
protected function getConnection( $key ) {
if ( count( $this->servers ) === 1 ) {
/**
* Log a fatal error
+ * @param string $msg
*/
protected function logError( $msg ) {
wfDebugLog( 'redis', "Redis error: $msg" );
* and protocol errors. Sometimes it also closes the connection, sometimes
* not. The safest response for us is to explicitly destroy the connection
* object and let it be reopened during the next request.
+ * @param RedisConnRef $conn
+ * @param Exception $e
*/
protected function handleException( RedisConnRef $conn, $e ) {
$this->setLastError( BagOStuff::ERR_UNEXPECTED );
/**
* Send information about a single request to the debug log
+ * @param string $method
+ * @param string $key
+ * @param string $server
+ * @param bool $result
*/
public function logRequest( $method, $key, $server, $result ) {
$this->debug( "$method $key on $server: " .
* distributed across all tables by key hash. This is for
* MySQL bugs 61735 and 61736.
*
- * @param $params array
+ * @param array $params
*/
public function __construct( $params ) {
if ( isset( $params['servers'] ) ) {
/**
* Get a connection to the specified database
*
- * @param $serverIndex integer
+ * @param int $serverIndex
* @return DatabaseBase
*/
protected function getDB( $serverIndex ) {
/**
* Get the server index and table name for a given key
- * @param $key string
- * @return Array: server index and table name
+ * @param string $key
+ * @return array Server index and table name
*/
protected function getTableByKey( $key ) {
if ( $this->shards > 1 ) {
/**
* Get the table name for a given shard index
- * @param $index int
+ * @param int $index
* @return string
*/
protected function getTableNameByShard( $index ) {
}
/**
- * @param $key string
- * @param $casToken[optional] mixed
+ * @param string $key
+ * @param mixed $casToken [optional]
* @return mixed
*/
public function get( $key, &$casToken = null ) {
}
/**
- * @param $keys array
- * @return Array
+ * @param array $keys
+ * @return array
*/
public function getMulti( array $keys ) {
$values = array(); // array of (key => value)
}
/**
- * @param $key string
- * @param $value mixed
- * @param $exptime int
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function set( $key, $value, $exptime = 0 ) {
}
/**
- * @param $casToken mixed
- * @param $key string
- * @param $value mixed
- * @param $exptime int
+ * @param mixed $casToken
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function cas( $casToken, $key, $value, $exptime = 0 ) {
}
/**
- * @param $key string
- * @param $time int
+ * @param string $key
+ * @param int $time
* @return bool
*/
public function delete( $key, $time = 0 ) {
}
/**
- * @param $key string
- * @param $step int
+ * @param string $key
+ * @param int $step
* @return int|null
*/
public function incr( $key, $step = 1 ) {
}
/**
- * @param $exptime string
+ * @param string $exptime
* @return bool
*/
protected function isExpired( $db, $exptime ) {
}
/**
+ * @param DatabaseBase $db
* @return string
*/
protected function getMaxDateTime( $db ) {
/**
* Delete objects from the database which expire before a certain date.
- * @param $timestamp string
- * @param $progressCallback bool|callback
+ * @param string $timestamp
+ * @param bool|callback $progressCallback
* @return bool
*/
public function deleteObjectsExpiringBefore( $timestamp, $progressCallback = false ) {
* On typical message and page data, this can provide a 3X decrease
* in storage requirements.
*
- * @param $data mixed
+ * @param mixed $data
* @return string
*/
protected function serialize( &$data ) {
/**
* Unserialize and, if necessary, decompress an object.
- * @param $serial string
+ * @param string $serial
* @return mixed
*/
protected function unserialize( $serial ) {
/**
* Handle a DBError which occurred during a read operation.
+ *
+ * @param DBError $exception
+ * @param int $serverIndex
*/
protected function handleReadError( DBError $exception, $serverIndex ) {
if ( $exception instanceof DBConnectionError ) {
/**
* Handle a DBQueryError which occurred during a write operation.
+ *
+ * @param DBError $exception
+ * @param int $serverIndex
*/
protected function handleWriteError( DBError $exception, $serverIndex ) {
if ( $exception instanceof DBConnectionError ) {
/**
* Mark a server down due to a DBConnectionError exception
+ *
+ * @param DBError $exception
+ * @param int $serverIndex
*/
protected function markServerDown( $exception, $serverIndex ) {
if ( isset( $this->connFailureTimes[$serverIndex] ) ) {
/**
* Get a value from the WinCache object cache
*
- * @param string $key cache key
- * @param $casToken[optional] int: cas token
+ * @param string $key Cache key
+ * @param int $casToken [optional] Cas token
* @return mixed
*/
public function get( $key, &$casToken = null ) {
/**
* Store a value in the WinCache object cache
*
- * @param string $key cache key
- * @param $value Mixed: object to store
- * @param int $expire expiration time
+ * @param string $key Cache key
+ * @param mixed $valueObject to store
+ * @param int $expire Expiration time
* @return bool
*/
public function set( $key, $value, $expire = 0 ) {
/**
* Store a value in the WinCache object cache, race condition-safe
*
- * @param int $casToken cas token
- * @param string $key cache key
- * @param int $value object to store
- * @param int $exptime expiration time
+ * @param int $casToken Cas token
+ * @param string $key Cache key
+ * @param int $value Object to store
+ * @param int $exptime Expiration time
* @return bool
*/
public function cas( $casToken, $key, $value, $exptime = 0 ) {
/**
* Remove a value from the WinCache object cache
*
- * @param string $key cache key
- * @param int $time not used in this implementation
+ * @param string $key Cache key
+ * @param int $time Not used in this implementation
* @return bool
*/
public function delete( $key, $time = 0 ) {
/**
* Get a value from the XCache object cache
*
- * @param string $key cache key
- * @param $casToken mixed: cas token
+ * @param string $key Cache key
+ * @param mixed $casToken Cas token
* @return mixed
*/
public function get( $key, &$casToken = null ) {
/**
* Store a value in the XCache object cache
*
- * @param string $key cache key
- * @param $value Mixed: object to store
- * @param int $expire expiration time
+ * @param string $key Cache key
+ * @param mixed $value Object to store
+ * @param int $expire Expiration time
* @return bool
*/
public function set( $key, $value, $expire = 0 ) {
}
/**
- * @param $casToken mixed
- * @param $key string
- * @param $value mixed
- * @param $exptime int
+ * @param mixed $casToken
+ * @param string $key
+ * @param mixed $value
+ * @param int $exptime
* @return bool
*/
public function cas( $casToken, $key, $value, $exptime = 0 ) {
/**
* Remove a value from the XCache object cache
*
- * @param string $key cache key
- * @param int $time not used in this implementation
+ * @param string $key Cache key
+ * @param int $time Not used in this implementation
* @return bool
*/
public function delete( $key, $time = 0 ) {
* XCache does not seem to support any way of performing CAS - this however will
* provide a way to perform CAS-like functionality.
*
- * @param $key string
- * @param $callback closure Callback method to be executed
+ * @param string $key
+ * @param closure $callback Callback method to be executed
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
- * @return bool success
+ * @return bool Cuccess
*/
public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) {
return $this->mergeViaLock( $key, $callback, $exptime, $attempts );