MediaWiki  REL1_19
SqlBagOStuff Class Reference

Class to store objects in the database. More...

Inheritance diagram for SqlBagOStuff:
Collaboration diagram for SqlBagOStuff:

List of all members.

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.

Detailed Description

Class to store objects in the database.

Definition at line 8 of file SqlBagOStuff.php.


Constructor & Destructor Documentation

Constructor.

Parameters are:

  • server: A server info structure in the format required by each element in $wgDBServers.
  • purgePeriod: The average number of object cache requests in between garbage collection operations, where expired entries are removed from the database. Or in other words, the reciprocal of the probability of purging on any given request. If this is set to zero, purging will never be done.
  • tableName: The table name to use, default is "objectcache".
  • shards: The number of tables to use for data storage. If this is more than 1, table names will be formed in the style objectcacheNNN where NNN is the shard index, between 0 and shards-1. The number of digits will be the minimum number required to hold the largest shard index. Data will be distributed across all tables by key hash. This is for MySQL bugs 61735 and 61736.
Parameters:
$paramsarray

Definition at line 49 of file SqlBagOStuff.php.


Member Function Documentation

Create shard tables.

For use from eval.php.

Definition at line 458 of file SqlBagOStuff.php.

References $db, and getDB().

Here is the call graph for this function:

SqlBagOStuff::delete ( key,
time = 0 
)

Delete an item.

Parameters:
$keystring
$timeint 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().

Here is the call graph for this function:

Definition at line 382 of file SqlBagOStuff.php.

References $db, getDB(), getTableByShard(), and handleWriteError().

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 307 of file SqlBagOStuff.php.

References deleteObjectsExpiringBefore(), and wfTimestampNow().

Referenced by garbageCollect().

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 290 of file SqlBagOStuff.php.

References expireAll().

Referenced by get().

Here is the call graph for this function:

Here is the caller graph for this function:

SqlBagOStuff::get ( key)

Get an item with the given key.

Returns false if it does not exist.

Parameters:
$keystring
Returns:
bool|Object

Reimplemented from BagOStuff.

Definition at line 118 of file SqlBagOStuff.php.

References $db, $tableName, BagOStuff\debug(), garbageCollect(), getDB(), getTableByKey(), handleWriteError(), isExpired(), and unserialize().

Here is the call graph for this function:

SqlBagOStuff::getDB ( ) [protected]
Returns:
DatabaseBase

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().

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 282 of file SqlBagOStuff.php.

References getDB().

Referenced by isExpired(), and set().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

SqlBagOStuff::incr ( key,
value = 1 
)
Parameters:
$keyString: Key to increase
$valueInteger: Value to add to $key (Default 1)
Returns:
null if lock is not possible else $key value increased by $value

Reimplemented from BagOStuff.

Definition at line 213 of file SqlBagOStuff.php.

References $db, $tableName, getDB(), getTableByKey(), handleWriteError(), isExpired(), and unserialize().

Here is the call graph for this function:

SqlBagOStuff::isExpired ( exptime) [protected]

Definition at line 278 of file SqlBagOStuff.php.

References getMaxDateTime(), and wfTimestamp().

Referenced by get(), and incr().

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from BagOStuff.

Definition at line 263 of file SqlBagOStuff.php.

References $db, $res, $result, getDB(), and getTableByShard().

Here is the call graph for this function:

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.

Parameters:
$datamixed
Returns:
string

Definition at line 404 of file SqlBagOStuff.php.

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

Set an item.

Parameters:
$keystring
$valuemixed
$exptimeint 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().

Here is the call graph for this function:

SqlBagOStuff::unserialize ( serial) [protected]

Unserialize and, if necessary, decompress an object.

Parameters:
$serialstring
Returns:
mixed

Definition at line 419 of file SqlBagOStuff.php.

References wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by get(), and incr().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

SqlBagOStuff::$db
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.

Referenced by get(), and incr().


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