MediaWiki
REL1_20
|
Public Member Functions | |
__construct ($params) | |
Construct a RedisBagOStuff object. | |
add ($key, $value, $expiry=0) | |
delete ($key, $time=0) | |
Delete an item. | |
get ($key) | |
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. | |
replace ($key, $value, $expiry=0) | |
Non-atomic implementation of replace(). | |
set ($key, $value, $expiry=0) | |
Set an item. | |
Public Attributes | |
$automaticFailover | |
$password | |
$persistent | |
Protected Member Functions | |
getConnection ($key) | |
Get a Redis object with a connection suitable for fetching the specified key. | |
getConnectionToServer ($server) | |
Get a connection to the server with the specified name. | |
handleException ($server, $e) | |
The redis extension throws an exception in response to various read, write and protocol errors. | |
logError ($msg) | |
Log a fatal error. | |
Protected Attributes | |
$connectTimeout | |
$conns = array() | |
A cache of Redis objects, representing connections to Redis servers. | |
$deadServers = array() | |
An array listing "dead" servers which have had a connection error in the past. | |
$servers | |
A list of server names, from $params['servers']. |
Definition at line 24 of file RedisBagOStuff.php.
RedisBagOStuff::__construct | ( | $ | params | ) |
Construct a RedisBagOStuff object.
Parameters are:
Definition at line 73 of file RedisBagOStuff.php.
References $params.
RedisBagOStuff::add | ( | $ | key, |
$ | value, | ||
$ | exptime = 0 |
||
) |
$key | string |
$value | mixed |
$exptime | integer |
Reimplemented from BagOStuff.
Definition at line 197 of file RedisBagOStuff.php.
References $result, $value, BagOStuff\convertToRelative(), getConnection(), handleException(), logRequest(), wfProfileIn(), and wfProfileOut().
RedisBagOStuff::delete | ( | $ | key, |
$ | time = 0 |
||
) |
Delete an item.
$key | string |
$time | int Amount of time to delay the operation (mostly memcached-specific) |
Reimplemented from BagOStuff.
Definition at line 136 of file RedisBagOStuff.php.
References $result, getConnection(), handleException(), logRequest(), wfProfileIn(), and wfProfileOut().
RedisBagOStuff::get | ( | $ | key | ) |
Get an item with the given key.
Returns false if it does not exist.
$key | string |
Reimplemented from BagOStuff.
Definition at line 93 of file RedisBagOStuff.php.
References $result, getConnection(), handleException(), logRequest(), wfProfileIn(), and wfProfileOut().
RedisBagOStuff::getConnection | ( | $ | key | ) | [protected] |
Get a Redis object with a connection suitable for fetching the specified key.
Definition at line 287 of file RedisBagOStuff.php.
References $hashes, and getConnectionToServer().
Referenced by add(), delete(), get(), getMulti(), incr(), replace(), and set().
RedisBagOStuff::getConnectionToServer | ( | $ | server | ) | [protected] |
Get a connection to the server with the specified name.
Connections are cached, and failures are persistent to avoid multiple timeouts.
Definition at line 320 of file RedisBagOStuff.php.
References $result, BagOStuff\debug(), logError(), IP\splitHostAndPort(), and wfDebugLog().
Referenced by getConnection().
RedisBagOStuff::getMulti | ( | array $ | keys | ) |
Get an associative array containing the item for each of the keys that have items.
$keys | Array List of strings |
Reimplemented from BagOStuff.
Definition at line 156 of file RedisBagOStuff.php.
References $conns, $result, $value, BagOStuff\debug(), getConnection(), handleException(), wfProfileIn(), and wfProfileOut().
RedisBagOStuff::handleException | ( | $ | server, |
$ | 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.
Definition at line 400 of file RedisBagOStuff.php.
References wfDebugLog().
Referenced by add(), delete(), get(), getMulti(), incr(), replace(), and set().
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.
Reimplemented from BagOStuff.
Definition at line 261 of file RedisBagOStuff.php.
References $result, $value, getConnection(), handleException(), logRequest(), wfProfileIn(), and wfProfileOut().
RedisBagOStuff::logError | ( | $ | msg | ) | [protected] |
Log a fatal error.
Definition at line 390 of file RedisBagOStuff.php.
References wfDebugLog().
Referenced by getConnectionToServer().
RedisBagOStuff::logRequest | ( | $ | method, |
$ | key, | ||
$ | server, | ||
$ | result | ||
) |
Send information about a single request to the debug log.
Definition at line 408 of file RedisBagOStuff.php.
References $result, and BagOStuff\debug().
Referenced by add(), delete(), get(), incr(), replace(), and set().
RedisBagOStuff::replace | ( | $ | key, |
$ | value, | ||
$ | expiry = 0 |
||
) |
Non-atomic implementation of replace().
Could perhaps be done atomically with WATCH or scripting, but this function is rarely used.
Reimplemented from BagOStuff.
Definition at line 223 of file RedisBagOStuff.php.
References $result, $value, BagOStuff\convertToRelative(), getConnection(), handleException(), logRequest(), wfProfileIn(), and wfProfileOut().
RedisBagOStuff::set | ( | $ | key, |
$ | value, | ||
$ | exptime = 0 |
||
) |
Set an item.
$key | string |
$value | mixed |
$exptime | int Either an interval in seconds or a unix timestamp for expiry |
Reimplemented from BagOStuff.
Definition at line 111 of file RedisBagOStuff.php.
References $result, $value, BagOStuff\convertToRelative(), getConnection(), handleException(), logRequest(), wfProfileIn(), and wfProfileOut().
RedisBagOStuff::$automaticFailover |
Definition at line 25 of file RedisBagOStuff.php.
RedisBagOStuff::$connectTimeout [protected] |
Definition at line 25 of file RedisBagOStuff.php.
RedisBagOStuff::$conns = array() [protected] |
A cache of Redis objects, representing connections to Redis servers.
The key is the server name.
Definition at line 36 of file RedisBagOStuff.php.
Referenced by getMulti().
RedisBagOStuff::$deadServers = array() [protected] |
An array listing "dead" servers which have had a connection error in the past.
Servers are marked dead for a limited period of time, to avoid excessive overhead from repeated connection timeouts. The key in the array is the server name, the value is the UNIX timestamp at which the server is resurrected.
Definition at line 45 of file RedisBagOStuff.php.
RedisBagOStuff::$password |
Definition at line 25 of file RedisBagOStuff.php.
RedisBagOStuff::$persistent |
Definition at line 25 of file RedisBagOStuff.php.
RedisBagOStuff::$servers [protected] |
A list of server names, from $params['servers'].
Definition at line 30 of file RedisBagOStuff.php.