MediaWiki
1.23.0
|
Public Member Functions | |
__construct ( $params) | |
Construct a RedisBagOStuff object. More... | |
add ( $key, $value, $expiry=0) | |
cas ( $casToken, $key, $value, $expiry=0) | |
Check and set an item. More... | |
delete ( $key, $time=0) | |
Delete an item. More... | |
get ( $key, &$casToken=null) | |
Get an item with the given key. More... | |
getMulti (array $keys) | |
Get an associative array containing the item for each of the keys that have items. More... | |
incr ( $key, $value=1) | |
Non-atomic implementation of incr(). More... | |
logRequest ( $method, $key, $server, $result) | |
Send information about a single request to the debug log. More... | |
set ( $key, $value, $expiry=0) | |
Set an item. More... | |
Public Member Functions inherited from BagOStuff | |
clearLastError () | |
Clear the "last error" registry. More... | |
debug ( $text) | |
decr ( $key, $value=1) | |
Decrease stored value of $key by $value while preserving its TTL. More... | |
deleteObjectsExpiringBefore ( $date, $progressCallback=false) | |
Delete all objects expiring before a certain date. More... | |
getLastError () | |
Get the "last error" registered; clearLastError() should be called manually. More... | |
lock ( $key, $timeout=6) | |
merge ( $key, closure $callback, $exptime=0, $attempts=10) | |
Merge changes into the existing cache value (possibly creating a new one). More... | |
replace ( $key, $value, $exptime=0) | |
setDebug ( $bool) | |
unlock ( $key) | |
Protected Member Functions | |
getConnection ( $key) | |
Get a Redis object with a connection suitable for fetching the specified key. More... | |
handleException (RedisConnRef $conn, $e) | |
The redis extension throws an exception in response to various read, write and protocol errors. More... | |
logError ( $msg) | |
Log a fatal error. More... | |
serialize ( $data) | |
unserialize ( $data) | |
Protected Member Functions inherited from BagOStuff | |
convertExpiry ( $exptime) | |
Convert an optionally relative time to an absolute time. More... | |
convertToRelative ( $exptime) | |
Convert an optionally absolute expiry time to a relative time. More... | |
isInteger ( $value) | |
Check if a value is an integer. More... | |
mergeViaCas ( $key, closure $callback, $exptime=0, $attempts=10) | |
mergeViaLock ( $key, closure $callback, $exptime=0, $attempts=10) | |
setLastError ( $err) | |
Set the "last error" registry. More... | |
Protected Attributes | |
bool | $automaticFailover |
RedisConnectionPool | $redisPool |
Array | $servers |
List of server names *. More... | |
Protected Attributes inherited from BagOStuff | |
$lastError = self::ERR_NONE | |
Additional Inherited Members | |
Public Attributes inherited from BagOStuff | |
const | ERR_NO_RESPONSE = 1 |
const | ERR_NONE = 0 |
Possible values for getLastError() More... | |
const | ERR_UNEXPECTED = 3 |
const | ERR_UNREACHABLE = 2 |
Definition at line 23 of file RedisBagOStuff.php.
RedisBagOStuff::__construct | ( | $params | ) |
Construct a RedisBagOStuff object.
Parameters are:
Definition at line 54 of file RedisBagOStuff.php.
References $params, array(), as, servers, and RedisConnectionPool\singleton().
RedisBagOStuff::add | ( | $key, | |
$value, | |||
$exptime = 0 |
|||
) |
$key | string |
$value | mixed |
$exptime | integer |
Reimplemented from BagOStuff.
Definition at line 210 of file RedisBagOStuff.php.
References $e, $section, array(), BagOStuff\convertToRelative(), getConnection(), handleException(), list, logRequest(), and serialize().
RedisBagOStuff::cas | ( | $casToken, | |
$key, | |||
$value, | |||
$exptime = 0 |
|||
) |
Check and set an item.
$casToken | mixed | |
$key | string | |
$value | mixed | |
int | $exptime | Either an interval in seconds or a unix timestamp for expiry |
Reimplemented from BagOStuff.
Definition at line 115 of file RedisBagOStuff.php.
References $e, $section, array(), BagOStuff\convertToRelative(), getConnection(), handleException(), list, logRequest(), and serialize().
RedisBagOStuff::delete | ( | $key, | |
$time = 0 |
|||
) |
Delete an item.
$key | string | |
int | $time | Amount of time to delay the operation (mostly memcached-specific) |
Reimplemented from BagOStuff.
Definition at line 149 of file RedisBagOStuff.php.
References $e, $section, getConnection(), handleException(), list, and logRequest().
RedisBagOStuff::get | ( | $key, | |
& | $casToken = null |
||
) |
Get an item with the given key.
Returns false if it does not exist.
$key | string |
$casToken[optional] | mixed |
Reimplemented from BagOStuff.
Definition at line 71 of file RedisBagOStuff.php.
References $e, $section, $value, getConnection(), handleException(), list, logRequest(), and unserialize().
|
protected |
Get a Redis object with a connection suitable for fetching the specified key.
Definition at line 288 of file RedisBagOStuff.php.
References $servers, array(), as, ArrayUtils\consistentHashSort(), BagOStuff\ERR_UNREACHABLE, servers, and BagOStuff\setLastError().
Referenced by add(), cas(), delete(), get(), getMulti(), incr(), and set().
RedisBagOStuff::getMulti | ( | array | $keys | ) |
Get an associative array containing the item for each of the keys that have items.
array | $keys | List of strings |
Reimplemented from BagOStuff.
Definition at line 169 of file RedisBagOStuff.php.
References $e, $keys, $section, $value, array(), as, BagOStuff\debug(), getConnection(), handleException(), list, and unserialize().
|
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 322 of file RedisBagOStuff.php.
References $e, BagOStuff\ERR_UNEXPECTED, and BagOStuff\setLastError().
Referenced by add(), cas(), delete(), get(), getMulti(), incr(), 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 245 of file RedisBagOStuff.php.
References $e, $section, $value, getConnection(), handleException(), list, logRequest(), and unserialize().
|
protected |
RedisBagOStuff::logRequest | ( | $method, | |
$key, | |||
$server, | |||
$result | |||
) |
Send information about a single request to the debug log.
Definition at line 330 of file RedisBagOStuff.php.
References BagOStuff\debug().
Referenced by add(), cas(), delete(), get(), incr(), and set().
|
protected |
RedisBagOStuff::set | ( | $key, | |
$value, | |||
$exptime = 0 |
|||
) |
Set an item.
$key | string | |
$value | mixed | |
int | $exptime | Either an interval in seconds or a unix timestamp for expiry |
Reimplemented from BagOStuff.
Definition at line 91 of file RedisBagOStuff.php.
References $e, $section, BagOStuff\convertToRelative(), getConnection(), handleException(), list, logRequest(), and serialize().
|
protected |
string | $data |
Definition at line 279 of file RedisBagOStuff.php.
Referenced by get(), getMulti(), and incr().
|
protected |
Definition at line 26 of file RedisBagOStuff.php.
|
protected |
Definition at line 24 of file RedisBagOStuff.php.
|
protected |
List of server names *.
Definition at line 25 of file RedisBagOStuff.php.
Referenced by getConnection().