MediaWiki master
MediaWiki\ExternalStore\ExternalStoreDB Class Reference

External storage in a SQL database. More...

Inherits MediaWiki\ExternalStore\ExternalStoreMedium.

Collaboration diagram for MediaWiki\ExternalStore\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 MediaWiki\ExternalStore\ExternalStoreMedium
 setLogger (LoggerInterface $logger)
 

Protected Member Functions

 parseURL ( $url)
 

Additional Inherited Members

- Protected Attributes inherited from MediaWiki\ExternalStore\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 29 of file ExternalStoreDB.php.

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from MediaWiki\ExternalStore\ExternalStoreMedium.

Definition at line 38 of file ExternalStoreDB.php.

References MediaWiki\ExternalStore\ExternalStoreMedium\$params.

Member Function Documentation

◆ batchFetchFromURLs()

MediaWiki\ExternalStore\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 MediaWiki\ExternalStore\ExternalStoreMedium.

Definition at line 77 of file ExternalStoreDB.php.

References $url, and MediaWiki\ExternalStore\ExternalStoreDB\parseURL().

◆ fetchFromURL()

MediaWiki\ExternalStore\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 MediaWiki\ExternalStore\ExternalStoreMedium.

Definition at line 56 of file ExternalStoreDB.php.

References $url, and MediaWiki\ExternalStore\ExternalStoreDB\parseURL().

◆ getClusterForUrl()

MediaWiki\ExternalStore\ExternalStoreDB::getClusterForUrl ( $url)

Get the cluster part of a URL.

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

Definition at line 423 of file ExternalStoreDB.php.

References $url.

◆ getDomainIdForCluster()

MediaWiki\ExternalStore\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 435 of file ExternalStoreDB.php.

References Wikimedia\Rdbms\ServerInfo\WRITER_INDEX.

◆ getPrimary()

MediaWiki\ExternalStore\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 171 of file ExternalStoreDB.php.

References DB_PRIMARY, and Wikimedia\Rdbms\ServerInfo\WRITER_INDEX.

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

◆ getReplica()

MediaWiki\ExternalStore\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 153 of file ExternalStoreDB.php.

References DB_REPLICA, and Wikimedia\Rdbms\ServerInfo\WRITER_INDEX.

◆ getTable()

MediaWiki\ExternalStore\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 219 of file ExternalStoreDB.php.

References Wikimedia\Rdbms\ServerInfo\WRITER_INDEX.

Referenced by MediaWiki\ExternalStore\ExternalStoreDB\initializeTable(), and MediaWiki\ExternalStore\ExternalStoreDB\store().

◆ initializeTable()

MediaWiki\ExternalStore\ExternalStoreDB::initializeTable ( $cluster)

Create the appropriate blobs table on this cluster.

Since
1.34
Parameters
string$cluster

Definition at line 232 of file ExternalStoreDB.php.

References $IP, MediaWiki\ExternalStore\ExternalStoreDB\getPrimary(), and MediaWiki\ExternalStore\ExternalStoreDB\getTable().

◆ isReadOnly()

MediaWiki\ExternalStore\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 MediaWiki\ExternalStore\ExternalStoreMedium.

Definition at line 128 of file ExternalStoreDB.php.

◆ parseURL()

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

Definition at line 406 of file ExternalStoreDB.php.

References $path, and $url.

Referenced by MediaWiki\ExternalStore\ExternalStoreDB\batchFetchFromURLs(), and MediaWiki\ExternalStore\ExternalStoreDB\fetchFromURL().

◆ store()

MediaWiki\ExternalStore\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 MediaWiki\ExternalStore\ExternalStoreMedium.

Definition at line 108 of file ExternalStoreDB.php.

References MediaWiki\ExternalStore\ExternalStoreDB\getPrimary(), and MediaWiki\ExternalStore\ExternalStoreDB\getTable().

Referenced by CgzCopyTransaction\commit().


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