MediaWiki  1.23.14
ExternalStore Class Reference

Constructor class for key/value blob data kept in external repositories. More...

Static Public Member Functions

static batchFetchFromURLs (array $urls)
 Fetch data from multiple URLs with a minimum of round trips. More...
 
static fetchFromURL ( $url, array $params=array())
 Fetch data from given URL. More...
 
static getStoreObject ( $proto, array $params=array())
 Get an external store object of the given type, with the given parameters. More...
 
static insert ( $url, $data, array $params=array())
 Store a data item to an external store, identified by a partial URL The protocol part is used to identify the class, the rest is passed to the class itself as a parameter. More...
 
static insertToDefault ( $data, array $params=array())
 Like insert() above, but does more of the work for us. More...
 
static insertToForeignDefault ( $data, $wiki)
 
static insertWithFallback (array $tryStores, $data, array $params=array())
 Like insert() above, but does more of the work for us. More...
 

Detailed Description

Constructor class for key/value blob data kept in external repositories.

Objects in external stores are defined by a special URL. The URL is of the form "<store protocol>://<location>/<object name>". The protocol is used to determine what ExternalStoreMedium class is used. The location identifies particular storage instances or database clusters for store class to use.

When an object is inserted into a store, the calling code uses a partial URL of the form "<store protocol>://<location>" and receives the full object URL on success. This is useful since object names can be sequential IDs, UUIDs, or hashes. Callers are not responsible for unique name generation.

External repositories might be populated by maintenance/async scripts, thus partial moving of data may be possible, as well as the possibility to have any storage format (i.e. for archives).

Definition at line 46 of file ExternalStore.php.

Member Function Documentation

◆ batchFetchFromURLs()

static ExternalStore::batchFetchFromURLs ( array  $urls)
static

Fetch data from multiple URLs with a minimum of round trips.

Parameters
array$urlsThe URLs of the text to get
Returns
array Map from url to its data. Data is either string when found or false on failure.

Definition at line 101 of file ExternalStore.php.

References $retval, array(), as, and getStoreObject().

◆ fetchFromURL()

static ExternalStore::fetchFromURL (   $url,
array  $params = array() 
)
static

Fetch data from given URL.

Parameters
string$urlThe URL of the text to get
array$paramsAssociative array of ExternalStoreMedium parameters
Returns
string|bool The text stored or false on error
Exceptions
MWException

Definition at line 75 of file ExternalStore.php.

References $params, $path, getStoreObject(), and list.

Referenced by DumpRev\execute(), FixBug20757\execute(), Revision\getRevisionText(), and ExternalStoreTest\testExternalFetchFromURL().

◆ getStoreObject()

static ExternalStore::getStoreObject (   $proto,
array  $params = array() 
)
static

Get an external store object of the given type, with the given parameters.

Parameters
string$protoType of external storage, should be a value in $wgExternalStores
array$paramsAssociative array of ExternalStoreMedium parameters
Returns
ExternalStoreMedium|bool The store class or false on error

Definition at line 54 of file ExternalStore.php.

References $params, and global.

Referenced by batchFetchFromURLs(), DumpRev\execute(), fetchFromURL(), insert(), and insertWithFallback().

◆ insert()

static ExternalStore::insert (   $url,
  $data,
array  $params = array() 
)
static

Store a data item to an external store, identified by a partial URL The protocol part is used to identify the class, the rest is passed to the class itself as a parameter.

Parameters
string$urlA partial external store URL ("<store type>://<location>")
$datastring
array$paramsAssociative array of ExternalStoreMedium parameters
Returns
string|bool The URL of the stored data item, or false on error
Exceptions
MWException

Definition at line 139 of file ExternalStore.php.

References $params, $path, getStoreObject(), and list.

◆ insertToDefault()

static ExternalStore::insertToDefault (   $data,
array  $params = array() 
)
static

Like insert() above, but does more of the work for us.

This function does not need a url param, it builds it by itself. It also fails-over to the next possible clusters provided by $wgDefaultExternalStore.

Parameters
string$data
array$paramsAssociative array of ExternalStoreMedium parameters
Returns
string|bool The URL of the stored data item, or false on error
Exceptions
MWException

Definition at line 169 of file ExternalStore.php.

References $params, array(), global, and insertWithFallback().

Referenced by Revision\insertOn(), and insertToForeignDefault().

◆ insertToForeignDefault()

static ExternalStore::insertToForeignDefault (   $data,
  $wiki 
)
static
Parameters
$datastring
$wikistring
Returns
string|bool The URL of the stored data item, or false on error
Exceptions
MWException

Definition at line 226 of file ExternalStore.php.

References array(), and insertToDefault().

◆ insertWithFallback()

static ExternalStore::insertWithFallback ( array  $tryStores,
  $data,
array  $params = array() 
)
static

Like insert() above, but does more of the work for us.

This function does not need a url param, it builds it by itself. It also fails-over to the next possible clusters as provided in the first parameter.

Parameters
array$tryStoresrefer to $wgDefaultExternalStore
string$data
array$paramsAssociative array of ExternalStoreMedium parameters
Returns
string|bool The URL of the stored data item, or false on error
Exceptions
MWException

Definition at line 187 of file ExternalStore.php.

References $error, $params, $path, getStoreObject(), list, wfDebug(), and wfDebugLog().

Referenced by insertToDefault().


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