MediaWiki master
ExternalStoreDB Class Reference

External storage in a SQL database. More...

Inherits ExternalStoreMedium.

Collaboration diagram for ExternalStoreDB:

Public Member Functions

 __construct (array $params)
 
 batchFetchFromURLs (array $urls)
 Fetch multiple URLs from given external store.
 
 fetchFromURL ( $url)
 Fetch data from given external store URL.
 
 getClusterForUrl ( $url)
 Get the cluster part of a URL.
 
 getDomainIdForCluster ( $cluster)
 Get the domain ID for a given cluster, which is false for the local wiki ID.
 
 getPrimary ( $cluster)
 Get a primary database connection for the specified cluster.
 
 getReplica ( $cluster)
 Get a replica DB connection for the specified cluster.
 
 getTable (string $cluster)
 Get the configured 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
ExternalStoreException

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

Protected Member Functions

 parseURL ( $url)
 

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

External storage in a SQL database.

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

See also
ExternalStoreAccess

Definition at line 38 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 47 of file ExternalStoreDB.php.

References $params.

Member Function Documentation

◆ batchFetchFromURLs()

ExternalStoreDB::batchFetchFromURLs ( array $urls)

Fetch multiple URLs from given external store.

The provided URLs are in the form of DB://cluster/id, or DB://cluster/id/itemid for concatenated storage if ConcatenatedGzipHistoryBlob was used.

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

References $url, and parseURL().

◆ fetchFromURL()

ExternalStoreDB::fetchFromURL ( $url)

Fetch data from given external store URL.

The provided URL is in the form of DB://cluster/id or DB://cluster/id/itemid for concatenated storage if ConcatenatedGzipHistoryBlob was used.

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

Reimplemented from ExternalStoreMedium.

Definition at line 65 of file ExternalStoreDB.php.

References $url, and parseURL().

◆ getClusterForUrl()

ExternalStoreDB::getClusterForUrl ( $url)

Get the cluster part of a URL.

Access: internal
for installer
Parameters
string$url
Returns
string|null

Definition at line 432 of file ExternalStoreDB.php.

References $url.

◆ getDomainIdForCluster()

ExternalStoreDB::getDomainIdForCluster ( $cluster)

Get the domain ID for a given cluster, which is false for the local wiki ID.

Access: internal
for installer
Parameters
string$cluster
Returns
string|false

Definition at line 444 of file ExternalStoreDB.php.

◆ getPrimary()

ExternalStoreDB::getPrimary ( $cluster)

Get a primary database connection for the specified cluster.

Parameters
string$clusterCluster name
Returns
\Wikimedia\Rdbms\IMaintainableDatabase
Since
1.37

Definition at line 180 of file ExternalStoreDB.php.

References DB_PRIMARY.

Referenced by CgzCopyTransaction\commit(), initializeTable(), and store().

◆ getReplica()

ExternalStoreDB::getReplica ( $cluster)

Get a replica DB connection for the specified cluster.

Since
1.34
Parameters
string$clusterCluster name
Returns
\Wikimedia\Rdbms\IReadableDatabase

Definition at line 162 of file ExternalStoreDB.php.

References DB_REPLICA.

◆ getTable()

ExternalStoreDB::getTable ( string $cluster)

Get the configured blobs table name for this database.

Typically, a suffix like "_clusterX" can be used to facilitate clean merging of read-only storage clusters by simply cloning tables to the new cluster servers.

Parameters
string$clusterCluster name
Returns
string Unqualified table name (e.g. "blobs_cluster32" or default "blobs")
Access: internal
Only for use within ExternalStoreDB and its core maintenance scripts

Definition at line 228 of file ExternalStoreDB.php.

Referenced by initializeTable(), and store().

◆ initializeTable()

ExternalStoreDB::initializeTable ( $cluster)

Create the appropriate blobs table on this cluster.

Since
1.34
Parameters
string$cluster

Definition at line 241 of file ExternalStoreDB.php.

References $IP, getPrimary(), 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 137 of file ExternalStoreDB.php.

◆ parseURL()

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

Definition at line 415 of file ExternalStoreDB.php.

References $path, and $url.

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
ExternalStoreException

Reimplemented from ExternalStoreMedium.

Definition at line 117 of file ExternalStoreDB.php.

References getPrimary(), and getTable().

Referenced by CgzCopyTransaction\commit().


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