MediaWiki REL1_30
ExternalStoreDB Class Reference

DB accessable external objects. More...

Inheritance diagram for ExternalStoreDB:
Collaboration diagram for ExternalStoreDB:

Public Member Functions

 batchFetchFromURLs (array $urls)
 Fetch data from given external store URLs.
 
 fetchFromURL ( $url)
 The provided URL is in the form of DB://cluster/id or DB://cluster/id/itemid for concatened storage.
 
 getMaster ( $cluster)
 Get a master database connection for the specified cluster.
 
 getSlave ( $cluster)
 Get a replica DB connection for the specified cluster.
 
 getTable ( $db)
 Get the 'blobs' table name for this database.
 
 store ( $location, $data)
 Insert a data item into a given location.
 
- Public Member Functions inherited from ExternalStoreMedium
 __construct (array $params=[])
 

Protected Member Functions

 parseURL ( $url)
 

Private Member Functions

 batchFetchBlobs ( $cluster, array $ids)
 Fetch multiple blob items out of the database.
 
 fetchBlob ( $cluster, $id, $itemID)
 Fetch a blob item out of the database; a cache of the last-loaded blob will be kept so that multiple loads out of a multi-item blob can avoid redundant database access and decompression.
 
 getLoadBalancer ( $cluster)
 Get a LoadBalancer for the specified cluster.
 
 mergeBatchResult (array &$ret, array &$ids, $res)
 Helper function for self::batchFetchBlobs for merging master/replica DB results.
 

Additional Inherited Members

- Protected Attributes inherited from ExternalStoreMedium
array $params = []
 

Detailed Description

DB accessable external objects.

In this system, each store "location" maps to a database "cluster". The clusters must be defined in the normal LBFactory configuration.

Definition at line 36 of file ExternalStoreDB.php.

Member Function Documentation

◆ batchFetchBlobs()

ExternalStoreDB::batchFetchBlobs ( $cluster,
array $ids )
private

Fetch multiple blob items out of the database.

Parameters
string$clusterA cluster name valid for use with LBFactory
array$idsA map from the blob_id's to look for to the requested itemIDs in the blobs
Returns
array A map from the blob_id's requested to their content. Unlocated ids are not represented

Definition at line 234 of file ExternalStoreDB.php.

References $dbr, $res, $ret, getMaster(), getSlave(), getTable(), mergeBatchResult(), and wfDebugLog().

Referenced by batchFetchFromURLs().

◆ batchFetchFromURLs()

ExternalStoreDB::batchFetchFromURLs ( array $urls)

Fetch data from given external store URLs.

The provided URLs are in the form of DB://cluster/id or DB://cluster/id/itemid for concatened storage.

Parameters
array$urlsAn array of external store URLs
Returns
array A map from url to stored content. Failed results are not represented.

Reimplemented from ExternalStoreMedium.

Definition at line 65 of file ExternalStoreDB.php.

References $blob, $res, $ret, $urls, batchFetchBlobs(), list, and parseURL().

◆ fetchBlob()

ExternalStoreDB::fetchBlob ( $cluster,
$id,
$itemID )
private

Fetch a blob item out of the database; a cache of the last-loaded blob will be kept so that multiple loads out of a multi-item blob can avoid redundant database access and decompression.

Parameters
string$cluster
string$id
string$itemID
Returns
HistoryBlob|bool Returns false if missing

Definition at line 181 of file ExternalStoreDB.php.

References $dbr, $ret, false, getMaster(), getSlave(), getTable(), unserialize(), and wfDebugLog().

Referenced by fetchFromURL().

◆ fetchFromURL()

ExternalStoreDB::fetchFromURL ( $url)

The provided URL is in the form of DB://cluster/id or DB://cluster/id/itemid for concatened storage.

Parameters
string$url
Returns
string|bool False if missing
See also
ExternalStoreMedium::fetchFromURL()

Reimplemented from ExternalStoreMedium.

Definition at line 45 of file ExternalStoreDB.php.

References $ret, fetchBlob(), list, and parseURL().

◆ getLoadBalancer()

ExternalStoreDB::getLoadBalancer ( $cluster)
private

Get a LoadBalancer for the specified cluster.

Parameters
string$clusterCluster name
Returns
LoadBalancer

Definition at line 112 of file ExternalStoreDB.php.

References wfGetLBFactory().

Referenced by getMaster(), and getSlave().

◆ getMaster()

ExternalStoreDB::getMaster ( $cluster)

Get a master database connection for the specified cluster.

Parameters
string$clusterCluster name
Returns
MaintainableDBConnRef

Definition at line 147 of file ExternalStoreDB.php.

References DB_MASTER, DBO_TRX, and getLoadBalancer().

Referenced by batchFetchBlobs(), fetchBlob(), and store().

◆ getSlave()

ExternalStoreDB::getSlave ( $cluster)

Get a replica DB connection for the specified cluster.

Parameters
string$clusterCluster name
Returns
DBConnRef

Definition at line 122 of file ExternalStoreDB.php.

References $wgDefaultExternalStore, DB_REPLICA, DBO_TRX, getLoadBalancer(), and wfDebug().

Referenced by batchFetchBlobs(), and fetchBlob().

◆ getTable()

ExternalStoreDB::getTable ( $db)

Get the 'blobs' table name for this database.

Parameters
IDatabase$db
Returns
string Table name ('blobs' by default)

Definition at line 163 of file ExternalStoreDB.php.

Referenced by batchFetchBlobs(), fetchBlob(), and store().

◆ mergeBatchResult()

ExternalStoreDB::mergeBatchResult ( array & $ret,
array & $ids,
$res )
private

Helper function for self::batchFetchBlobs for merging master/replica DB results.

Parameters
array&$retCurrent self::batchFetchBlobs return value
array&$idsMap from blob_id to requested itemIDs
mixed$resDB result from Database::select

Definition at line 273 of file ExternalStoreDB.php.

References $res, $ret, and unserialize().

Referenced by batchFetchBlobs().

◆ parseURL()

ExternalStoreDB::parseURL ( $url)
protected
Parameters
string$url
Returns
array

Definition at line 292 of file ExternalStoreDB.php.

Referenced by batchFetchFromURLs(), and fetchFromURL().

◆ store()

ExternalStoreDB::store ( $location,
$data )

Insert a data item into a given location.

Parameters
string$locationThe location name
string$dataThe data item
Returns
string|bool The URL of the stored data item, or false on error
Exceptions
MWException

Reimplemented from ExternalStoreMedium.

Definition at line 93 of file ExternalStoreDB.php.

References getMaster(), and getTable().

Referenced by CompressOld\compressPage().


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