MediaWiki  REL1_24
RedisBagOStuff Class Reference
Inheritance diagram for RedisBagOStuff:
Collaboration diagram for RedisBagOStuff:

List of all members.

Public Member Functions

 __construct ($params)
 Construct a RedisBagOStuff object.
 add ($key, $value, $expiry=0)
 cas ($casToken, $key, $value, $expiry=0)
 Check and set an item.
 delete ($key, $time=0)
 Delete an item.
 get ($key, &$casToken=null)
 Get an item with the given key.
 getMulti (array $keys)
 Get an associative array containing the item for each of the keys that have items.
 incr ($key, $value=1)
 Non-atomic implementation of incr().
 logRequest ($method, $key, $server, $result)
 Send information about a single request to the debug log.
 set ($key, $value, $expiry=0)
 Set an item.
 setMulti (array $data, $expiry=0)

Protected Member Functions

 getConnection ($key)
 Get a Redis object with a connection suitable for fetching the specified key.
 handleException (RedisConnRef $conn, $e)
 The redis extension throws an exception in response to various read, write and protocol errors.
 logError ($msg)
 Log a fatal error.
 serialize ($data)
 unserialize ($data)

Protected Attributes

bool $automaticFailover
 *
RedisConnectionPool $redisPool
 *
array $servers
 List of server names *.

Detailed Description

Definition at line 23 of file RedisBagOStuff.php.


Constructor & Destructor Documentation

Construct a RedisBagOStuff object.

Parameters are:

  • servers: An array of server names. A server name may be a hostname, a hostname/port combination or the absolute path of a UNIX socket. If a hostname is specified but no port, the standard port number 6379 will be used. Required.
  • connectTimeout: The timeout for new connections, in seconds. Optional, default is 1 second.
  • persistent: Set this to true to allow connections to persist across multiple web requests. False by default.
  • password: The authentication password, will be sent to Redis in clear text. Optional, if it is unspecified, no AUTH command will be sent.
  • automaticFailover: If this is false, then each key will be mapped to a single server, and if that server is down, any requests for that key will fail. If this is true, a connection failure will cause the client to immediately try the next server in the list (as determined by a 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.
    Parameters:
    array$params

Definition at line 55 of file RedisBagOStuff.php.


Member Function Documentation

RedisBagOStuff::add ( key,
value,
exptime = 0 
)
Parameters:
string$key
mixed$value
int$exptime
Returns:
bool Success

Reimplemented from BagOStuff.

Definition at line 264 of file RedisBagOStuff.php.

References $e, $result, $section, $value, array(), BagOStuff\convertToRelative(), getConnection(), handleException(), list, logRequest(), and serialize().

RedisBagOStuff::cas ( casToken,
key,
value,
exptime = 0 
)

Check and set an item.

Parameters:
mixed$casToken
string$key
mixed$value
int$exptimeEither an interval in seconds or a unix timestamp for expiry
Returns:
bool Success

Reimplemented from BagOStuff.

Definition at line 116 of file RedisBagOStuff.php.

RedisBagOStuff::delete ( key,
time = 0 
)

Delete an item.

Parameters:
string$key
int$timeAmount of time to delay the operation (mostly memcached-specific)
Returns:
bool True if the item was deleted or not found, false on failure

Reimplemented from BagOStuff.

Definition at line 150 of file RedisBagOStuff.php.

RedisBagOStuff::get ( key,
&$  casToken = null 
)

Get an item with the given key.

Returns false if it does not exist.

Parameters:
string$key
mixed$casToken[optional]
Returns:
mixed Returns false on failure

Reimplemented from BagOStuff.

Definition at line 72 of file RedisBagOStuff.php.

RedisBagOStuff::getConnection ( key) [protected]

Get a Redis object with a connection suitable for fetching the specified key.

Parameters:
string$key
Returns:
array (server, RedisConnRef) or (false, false)

Definition at line 345 of file RedisBagOStuff.php.

Referenced by add().

Get an associative array containing the item for each of the keys that have items.

Parameters:
array$keysList of strings
Returns:
array

Reimplemented from BagOStuff.

Definition at line 170 of file RedisBagOStuff.php.

RedisBagOStuff::handleException ( RedisConnRef conn,
e 
) [protected]

The redis extension throws an exception in response to various read, write 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.

Parameters:
RedisConnRef$conn
Exception$e

Definition at line 382 of file RedisBagOStuff.php.

Referenced by add().

RedisBagOStuff::incr ( key,
value = 1 
)

Non-atomic implementation of incr().

Probably all callers actually want incr() to atomically initialise values to zero if they don't exist, as provided by the Redis INCR command. But we are constrained by the memcached-like interface to return null in that case. Once the key exists, further increments are atomic.

Parameters:
string$keyKey to increase
int$valueValue to add to $key (Default 1)
Returns:
int|bool New value or false on failure

Reimplemented from BagOStuff.

Definition at line 302 of file RedisBagOStuff.php.

RedisBagOStuff::logError ( msg) [protected]

Log a fatal error.

Parameters:
string$msg

Definition at line 370 of file RedisBagOStuff.php.

RedisBagOStuff::logRequest ( method,
key,
server,
result 
)

Send information about a single request to the debug log.

Parameters:
string$method
string$key
string$server
bool$result

Definition at line 394 of file RedisBagOStuff.php.

Referenced by add().

RedisBagOStuff::serialize ( data) [protected]
Parameters:
mixed$data
Returns:
string

Definition at line 326 of file RedisBagOStuff.php.

Referenced by add().

RedisBagOStuff::set ( key,
value,
exptime = 0 
)

Set an item.

Parameters:
string$key
mixed$value
int$exptimeEither an interval in seconds or a unix timestamp for expiry
Returns:
bool Success

Reimplemented from BagOStuff.

Definition at line 92 of file RedisBagOStuff.php.

RedisBagOStuff::setMulti ( array data,
expiry = 0 
)
Parameters:
array$data
int$expiry
Returns:
bool

Reimplemented from BagOStuff.

Definition at line 216 of file RedisBagOStuff.php.

RedisBagOStuff::unserialize ( data) [protected]
Parameters:
string$data
Returns:
mixed

Definition at line 336 of file RedisBagOStuff.php.


Member Data Documentation

bool RedisBagOStuff::$automaticFailover [protected]

*

Definition at line 26 of file RedisBagOStuff.php.

RedisConnectionPool RedisBagOStuff::$redisPool [protected]

*

Definition at line 24 of file RedisBagOStuff.php.

array RedisBagOStuff::$servers [protected]

List of server names *.

Definition at line 25 of file RedisBagOStuff.php.


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