MediaWiki
1.23.5
|
Class to store objects in the database. More...
Public Member Functions | |
__construct ( $params) | |
Constructor. More... | |
cas ( $casToken, $key, $value, $exptime=0) | |
createTables () | |
Create shard tables. More... | |
delete ( $key, $time=0) | |
deleteAll () | |
deleteObjectsExpiringBefore ( $timestamp, $progressCallback=false) | |
Delete objects from the database which expire before a certain date. More... | |
expireAll () | |
get ( $key, &$casToken=null) | |
getMulti (array $keys) | |
incr ( $key, $step=1) | |
set ( $key, $value, $exptime=0) | |
Public Member Functions inherited from BagOStuff | |
add ( $key, $value, $exptime=0) | |
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... | |
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) | |
Public Attributes | |
$conns | |
$lastExpireAll = 0 | |
LoadBalancer | $lb |
$numServers | |
$purgePeriod = 100 | |
$serverInfos | |
$serverNames | |
$shards = 1 | |
$tableName = 'objectcache' | |
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 |
Protected Member Functions | |
garbageCollect () | |
getDB ( $serverIndex) | |
Get a connection to the specified database. More... | |
getMaxDateTime ( $db) | |
getTableByKey ( $key) | |
Get the server index and table name for a given key. More... | |
getTableNameByShard ( $index) | |
Get the table name for a given shard index. More... | |
handleReadError (DBError $exception, $serverIndex) | |
Handle a DBError which occurred during a read operation. More... | |
handleWriteError (DBError $exception, $serverIndex) | |
Handle a DBQueryError which occurred during a write operation. More... | |
isExpired ( $db, $exptime) | |
markServerDown ( $exception, $serverIndex) | |
Mark a server down due to a DBConnectionError exception. More... | |
serialize (&$data) | |
Serialize an object and, if possible, compress the representation. More... | |
unserialize ( $serial) | |
Unserialize and, if necessary, decompress an object. More... | |
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 | |
$connFailureErrors = array() | |
$connFailureTimes = array() | |
Protected Attributes inherited from BagOStuff | |
$lastError = self::ERR_NONE | |
Class to store objects in the database.
Definition at line 29 of file SqlBagOStuff.php.
SqlBagOStuff::__construct | ( | $params | ) |
Constructor.
Parameters are:
$params | array |
Definition at line 74 of file SqlBagOStuff.php.
References $params, array(), as, and tableName().
SqlBagOStuff::cas | ( | $casToken, | |
$key, | |||
$value, | |||
$exptime = 0 |
|||
) |
$casToken | mixed |
$key | string |
$value | mixed |
$exptime | int |
Reimplemented from BagOStuff.
Definition at line 328 of file SqlBagOStuff.php.
References $e, $tableName, $value, array(), getDB(), getMaxDateTime(), getTableByKey(), handleWriteError(), and list.
SqlBagOStuff::createTables | ( | ) |
Create shard tables.
For use from eval.php.
Definition at line 683 of file SqlBagOStuff.php.
References $numServers, $shards, and getDB().
SqlBagOStuff::delete | ( | $key, | |
$time = 0 |
|||
) |
$key | string |
$time | int |
Reimplemented from BagOStuff.
Definition at line 377 of file SqlBagOStuff.php.
References $e, $tableName, array(), getDB(), getTableByKey(), handleWriteError(), and list.
SqlBagOStuff::deleteAll | ( | ) |
Definition at line 566 of file SqlBagOStuff.php.
References $e, $numServers, $shards, getDB(), getTableNameByShard(), and handleWriteError().
SqlBagOStuff::deleteObjectsExpiringBefore | ( | $timestamp, | |
$progressCallback = false |
|||
) |
Delete objects from the database which expire before a certain date.
$timestamp | string |
$progressCallback | bool|callback |
Reimplemented from BagOStuff.
Definition at line 494 of file SqlBagOStuff.php.
References $e, $keys, $numServers, $shards, $timestamp, array(), as, getDB(), getTableNameByShard(), handleWriteError(), TS_UNIX, and wfTimestamp().
Referenced by expireAll().
SqlBagOStuff::expireAll | ( | ) |
Definition at line 484 of file SqlBagOStuff.php.
References deleteObjectsExpiringBefore(), and wfTimestampNow().
Referenced by garbageCollect().
|
protected |
SqlBagOStuff::get | ( | $key, | |
& | $casToken = null |
||
) |
$key | string |
$casToken[optional] | mixed |
Reimplemented from BagOStuff.
Definition at line 198 of file SqlBagOStuff.php.
References array(), and getMulti().
|
protected |
Get a connection to the specified database.
$serverIndex | integer |
Definition at line 106 of file SqlBagOStuff.php.
References $type, DB_MASTER, DBO_TRX, DatabaseBase\factory(), global, wfDebug(), wfGetDB(), and wfGetLBFactory().
Referenced by cas(), createTables(), delete(), deleteAll(), deleteObjectsExpiringBefore(), getMulti(), incr(), and set().
|
protected |
Definition at line 459 of file SqlBagOStuff.php.
Referenced by cas(), isExpired(), and set().
SqlBagOStuff::getMulti | ( | array | $keys | ) |
$keys | array |
Reimplemented from BagOStuff.
Definition at line 211 of file SqlBagOStuff.php.
References $e, $keys, $res, $tableName, array(), as, BagOStuff\debug(), garbageCollect(), getDB(), getTableByKey(), handleReadError(), handleWriteError(), isExpired(), list, and unserialize().
Referenced by get().
|
protected |
Get the server index and table name for a given key.
$key | string |
Definition at line 160 of file SqlBagOStuff.php.
References $hash, $serverNames, $shards, array(), ArrayUtils\consistentHashSort(), getTableNameByShard(), and key.
Referenced by cas(), delete(), getMulti(), incr(), and set().
|
protected |
Get the table name for a given shard index.
$index | int |
Definition at line 183 of file SqlBagOStuff.php.
References $tableName, and tableName().
Referenced by deleteAll(), deleteObjectsExpiringBefore(), and getTableByKey().
|
protected |
Handle a DBError which occurred during a read operation.
Definition at line 625 of file SqlBagOStuff.php.
References BagOStuff\ERR_UNEXPECTED, BagOStuff\ERR_UNREACHABLE, markServerDown(), BagOStuff\setLastError(), wfDebug(), and wfDebugLog().
Referenced by getMulti().
|
protected |
Handle a DBQueryError which occurred during a write operation.
Definition at line 642 of file SqlBagOStuff.php.
References $e, BagOStuff\ERR_UNEXPECTED, BagOStuff\ERR_UNREACHABLE, markServerDown(), BagOStuff\setLastError(), wfDebug(), and wfDebugLog().
Referenced by cas(), delete(), deleteAll(), deleteObjectsExpiringBefore(), getMulti(), incr(), and set().
SqlBagOStuff::incr | ( | $key, | |
$step = 1 |
|||
) |
$key | string |
$step | int |
Reimplemented from BagOStuff.
Definition at line 400 of file SqlBagOStuff.php.
References $e, $tableName, array(), getDB(), getTableByKey(), handleWriteError(), isExpired(), list, and unserialize().
|
protected |
$exptime | string |
Definition at line 452 of file SqlBagOStuff.php.
References getMaxDateTime(), TS_UNIX, and wfTimestamp().
Referenced by getMulti(), and incr().
|
protected |
Mark a server down due to a DBConnectionError exception.
Definition at line 664 of file SqlBagOStuff.php.
References wfDebug().
Referenced by handleReadError(), and handleWriteError().
|
protected |
Serialize an object and, if possible, compress the representation.
On typical message and page data, this can provide a 3X decrease in storage requirements.
$data | mixed |
Definition at line 591 of file SqlBagOStuff.php.
SqlBagOStuff::set | ( | $key, | |
$value, | |||
$exptime = 0 |
|||
) |
$key | string |
$value | mixed |
$exptime | int |
Reimplemented from BagOStuff.
Definition at line 282 of file SqlBagOStuff.php.
References $e, $tableName, $value, array(), getDB(), getMaxDateTime(), getTableByKey(), handleWriteError(), and list.
|
protected |
Unserialize and, if necessary, decompress an object.
$serial | string |
Definition at line 606 of file SqlBagOStuff.php.
References $ret, wfRestoreWarnings(), and wfSuppressWarnings().
Referenced by getMulti(), and incr().
|
protected |
Definition at line 44 of file SqlBagOStuff.php.
|
protected |
Definition at line 43 of file SqlBagOStuff.php.
SqlBagOStuff::$conns |
Definition at line 37 of file SqlBagOStuff.php.
SqlBagOStuff::$lastExpireAll = 0 |
Definition at line 38 of file SqlBagOStuff.php.
LoadBalancer SqlBagOStuff::$lb |
Definition at line 32 of file SqlBagOStuff.php.
SqlBagOStuff::$numServers |
Definition at line 36 of file SqlBagOStuff.php.
Referenced by createTables(), deleteAll(), and deleteObjectsExpiringBefore().
SqlBagOStuff::$purgePeriod = 100 |
Definition at line 39 of file SqlBagOStuff.php.
SqlBagOStuff::$serverInfos |
Definition at line 34 of file SqlBagOStuff.php.
SqlBagOStuff::$serverNames |
Definition at line 35 of file SqlBagOStuff.php.
Referenced by getTableByKey().
SqlBagOStuff::$shards = 1 |
Definition at line 40 of file SqlBagOStuff.php.
Referenced by createTables(), deleteAll(), deleteObjectsExpiringBefore(), and getTableByKey().
SqlBagOStuff::$tableName = 'objectcache' |
Definition at line 41 of file SqlBagOStuff.php.
Referenced by cas(), delete(), getMulti(), getTableNameByShard(), incr(), and set().