|
MediaWiki
REL1_19
|
Class to store objects in the database. More...


Public Member Functions | |
| __construct ($params) | |
| Constructor. | |
| createTables () | |
| Create shard tables. | |
| delete ($key, $time=0) | |
| Delete an item. | |
| deleteAll () | |
| deleteObjectsExpiringBefore ($timestamp, $progressCallback=false) | |
| Delete objects from the database which expire before a certain date. | |
| expireAll () | |
| get ($key) | |
| Get an item with the given key. | |
| incr ($key, $step=1) | |
| keys () | |
| set ($key, $value, $exptime=0) | |
| Set an item. | |
Public Attributes | |
| $db | |
| $lastExpireAll = 0 | |
| $lb | |
| $purgePeriod = 100 | |
| $serverInfo | |
| $shards = 1 | |
| $tableName = 'objectcache' | |
Protected Member Functions | |
| garbageCollect () | |
| getDB () | |
| getMaxDateTime () | |
| getTableByKey ($key) | |
| Get the table name for a given key. | |
| getTableByShard ($index) | |
| Get the table name for a given shard index. | |
| handleWriteError ($exception) | |
| Handle a DBQueryError which occurred during a write operation. | |
| isExpired ($exptime) | |
| serialize (&$data) | |
| Serialize an object and, if possible, compress the representation. | |
| unserialize ($serial) | |
| Unserialize and, if necessary, decompress an object. | |
Class to store objects in the database.
Definition at line 8 of file SqlBagOStuff.php.
| SqlBagOStuff::__construct | ( | $ | params | ) |
Constructor.
Parameters are:
| $params | array |
Definition at line 49 of file SqlBagOStuff.php.
Create shard tables.
For use from eval.php.
Definition at line 458 of file SqlBagOStuff.php.

| SqlBagOStuff::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 194 of file SqlBagOStuff.php.
References $db, getDB(), getTableByKey(), and handleWriteError().

Definition at line 382 of file SqlBagOStuff.php.
References $db, getDB(), getTableByShard(), and handleWriteError().

| SqlBagOStuff::deleteObjectsExpiringBefore | ( | $ | timestamp, |
| $ | progressCallback = false |
||
| ) |
Delete objects from the database which expire before a certain date.
Reimplemented from BagOStuff.
Definition at line 314 of file SqlBagOStuff.php.
References $db, $keys, $rows, getDB(), getTableByShard(), handleWriteError(), and wfTimestamp().
Referenced by expireAll().


Definition at line 307 of file SqlBagOStuff.php.
References deleteObjectsExpiringBefore(), and wfTimestampNow().
Referenced by garbageCollect().


| SqlBagOStuff::garbageCollect | ( | ) | [protected] |
Definition at line 290 of file SqlBagOStuff.php.
References expireAll().
Referenced by get().


| SqlBagOStuff::get | ( | $ | key | ) |
Get an item with the given key.
Returns false if it does not exist.
| $key | string |
Reimplemented from BagOStuff.
Definition at line 118 of file SqlBagOStuff.php.
References $db, $tableName, BagOStuff\debug(), garbageCollect(), getDB(), getTableByKey(), handleWriteError(), isExpired(), and unserialize().

| SqlBagOStuff::getDB | ( | ) | [protected] |
Definition at line 68 of file SqlBagOStuff.php.
References wfGetDB(), and wfGetLBFactory().
Referenced by createTables(), delete(), deleteAll(), deleteObjectsExpiringBefore(), get(), getMaxDateTime(), handleWriteError(), incr(), keys(), and set().


| SqlBagOStuff::getMaxDateTime | ( | ) | [protected] |
Definition at line 282 of file SqlBagOStuff.php.
References getDB().
Referenced by isExpired(), and set().


| SqlBagOStuff::getTableByKey | ( | $ | key | ) | [protected] |
Get the table name for a given key.
Definition at line 96 of file SqlBagOStuff.php.
References getTableByShard().
Referenced by delete(), get(), incr(), and set().


| SqlBagOStuff::getTableByShard | ( | $ | index | ) | [protected] |
Get the table name for a given shard index.
Definition at line 108 of file SqlBagOStuff.php.
Referenced by deleteAll(), deleteObjectsExpiringBefore(), getTableByKey(), and keys().

| SqlBagOStuff::handleWriteError | ( | $ | exception | ) | [protected] |
Handle a DBQueryError which occurred during a write operation.
Ignore errors which are due to a read-only database, rethrow others.
Definition at line 439 of file SqlBagOStuff.php.
References $db, getDB(), and wfDebug().
Referenced by delete(), deleteAll(), deleteObjectsExpiringBefore(), get(), incr(), and set().


| SqlBagOStuff::incr | ( | $ | key, |
| $ | value = 1 |
||
| ) |
| $key | String: Key to increase |
| $value | Integer: Value to add to $key (Default 1) |
Reimplemented from BagOStuff.
Definition at line 213 of file SqlBagOStuff.php.
References $db, $tableName, getDB(), getTableByKey(), handleWriteError(), isExpired(), and unserialize().

| SqlBagOStuff::isExpired | ( | $ | exptime | ) | [protected] |
Definition at line 278 of file SqlBagOStuff.php.
References getMaxDateTime(), and wfTimestamp().
Referenced by get(), and incr().


Reimplemented from BagOStuff.
Definition at line 263 of file SqlBagOStuff.php.
References $db, $res, $result, getDB(), and getTableByShard().

| SqlBagOStuff::serialize | ( | &$ | data | ) | [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 404 of file SqlBagOStuff.php.
| SqlBagOStuff::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 155 of file SqlBagOStuff.php.
References $db, getDB(), getMaxDateTime(), getTableByKey(), and handleWriteError().

| SqlBagOStuff::unserialize | ( | $ | serial | ) | [protected] |
Unserialize and, if necessary, decompress an object.
| $serial | string |
Definition at line 419 of file SqlBagOStuff.php.
References wfRestoreWarnings(), and wfSuppressWarnings().
Referenced by get(), and incr().


| SqlBagOStuff::$db |
Definition at line 18 of file SqlBagOStuff.php.
Referenced by createTables(), delete(), deleteAll(), deleteObjectsExpiringBefore(), get(), handleWriteError(), incr(), keys(), and set().
| SqlBagOStuff::$lastExpireAll = 0 |
Definition at line 20 of file SqlBagOStuff.php.
| SqlBagOStuff::$lb |
Definition at line 13 of file SqlBagOStuff.php.
| SqlBagOStuff::$purgePeriod = 100 |
Definition at line 21 of file SqlBagOStuff.php.
| SqlBagOStuff::$serverInfo |
Definition at line 19 of file SqlBagOStuff.php.
| SqlBagOStuff::$shards = 1 |
Definition at line 22 of file SqlBagOStuff.php.
| SqlBagOStuff::$tableName = 'objectcache' |
Definition at line 23 of file SqlBagOStuff.php.