MediaWiki REL1_34
ExternalStoreDB Class Reference

DB accessible external objects. More...

Inheritance diagram for ExternalStoreDB:
Collaboration diagram for ExternalStoreDB:

Public Member Functions

 __construct (array $params)
 
 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.
 
 getReplica ( $cluster)
 Get a replica DB connection for the specified cluster.
 
 getSlave ( $cluster)
 Get a replica DB connection for the specified cluster.
 
 getTable ( $db, $cluster=null)
 Get the 'blobs' table name for this database.
 
 initializeTable ( $cluster)
 Create the appropriate blobs table on this cluster.
 
 isReadOnly ( $location)
 Check if a given location is read-only.
Parameters
string$locationThe location name
Returns
bool Whether this location is read-only
Since
1.31

 
 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

 
- Public Member Functions inherited from ExternalStoreMedium
 setLogger (LoggerInterface $logger)
 

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.
 
 getDomainId (array $server)
 
 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.
 

Private Attributes

LBFactory $lbFactory
 

Additional Inherited Members

- Protected Attributes inherited from ExternalStoreMedium
string $dbDomain
 Default database domain to store content under.
 
bool $isDbDomainExplicit
 Whether this was factoried with an explicit DB domain.
 
LoggerInterface $logger
 
array $params = []
 Usage context options for this instance.
 

Detailed Description

DB accessible 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 39 of file ExternalStoreDB.php.

Constructor & Destructor Documentation

◆ __construct()

ExternalStoreDB::__construct ( array  $params)
See also
ExternalStoreMedium::__construct()
Parameters
array$paramsAdditional parameters include:
  • lbFactory: an LBFactory instance

Reimplemented from ExternalStoreMedium.

Definition at line 48 of file ExternalStoreDB.php.

References ExternalStoreMedium\$params.

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 350 of file ExternalStoreDB.php.

References $dbr, $res, getMaster(), getReplica(), getTable(), and mergeBatchResult().

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 84 of file ExternalStoreDB.php.

References $blob, $res, $urls, batchFetchBlobs(), 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 291 of file ExternalStoreDB.php.

References $dbr, getMaster(), getReplica(), getTable(), and unserialize().

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 64 of file ExternalStoreDB.php.

References fetchBlob(), and parseURL().

◆ getDomainId()

ExternalStoreDB::getDomainId ( array  $server)
private
Parameters
array$serverMaster DB server configuration array for LoadBalancer
Returns
string|bool Database domain ID or false

Definition at line 204 of file ExternalStoreDB.php.

References ExternalStoreMedium\$dbDomain.

Referenced by getMaster(), getReplica(), and isReadOnly().

◆ getLoadBalancer()

ExternalStoreDB::getLoadBalancer (   $cluster)
private

Get a LoadBalancer for the specified cluster.

Parameters
string$clusterCluster name
Returns
ILoadBalancer

Definition at line 150 of file ExternalStoreDB.php.

Referenced by getMaster(), getReplica(), getTable(), and isReadOnly().

◆ getMaster()

ExternalStoreDB::getMaster (   $cluster)

Get a master database connection for the specified cluster.

Parameters
string$clusterCluster name
Returns
MaintainableDBConnRef

Definition at line 189 of file ExternalStoreDB.php.

References DB_MASTER, getDomainId(), and getLoadBalancer().

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

◆ getReplica()

ExternalStoreDB::getReplica (   $cluster)

Get a replica DB connection for the specified cluster.

Since
1.34
Parameters
string$clusterCluster name
Returns
DBConnRef

Definition at line 161 of file ExternalStoreDB.php.

References DB_REPLICA, getDomainId(), and getLoadBalancer().

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

◆ getSlave()

ExternalStoreDB::getSlave (   $cluster)

Get a replica DB connection for the specified cluster.

Parameters
string$clusterCluster name
Returns
DBConnRef
Deprecated:
since 1.34

Definition at line 179 of file ExternalStoreDB.php.

References getReplica().

◆ getTable()

ExternalStoreDB::getTable (   $db,
  $cluster = null 
)

Get the 'blobs' table name for this database.

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

Definition at line 234 of file ExternalStoreDB.php.

References getLoadBalancer().

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

◆ initializeTable()

ExternalStoreDB::initializeTable (   $cluster)

Create the appropriate blobs table on this cluster.

See also
getTable()
Since
1.34
Parameters
string$cluster

Definition at line 253 of file ExternalStoreDB.php.

References $IP, getMaster(), and getTable().

◆ isReadOnly()

ExternalStoreDB::isReadOnly (   $location)

Check if a given location is read-only.

Parameters
string$locationThe location name
Returns
bool Whether this location is read-only
Since
1.31

Reimplemented from ExternalStoreMedium.

Definition at line 133 of file ExternalStoreDB.php.

References getDomainId(), and getLoadBalancer().

◆ 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 397 of file ExternalStoreDB.php.

References $res, and unserialize().

Referenced by batchFetchBlobs().

◆ parseURL()

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

Definition at line 416 of file ExternalStoreDB.php.

References $path.

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 115 of file ExternalStoreDB.php.

References getMaster(), and getTable().

Member Data Documentation

◆ $lbFactory

LBFactory ExternalStoreDB::$lbFactory
private

Definition at line 41 of file ExternalStoreDB.php.


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