*
* sectionLoads A 2-d map. For each section, gives a map of server names to
* load ratios. For example:
- * array(
- * 'section1' => array(
+ * [
+ * 'section1' => [
* 'db1' => 100,
* 'db2' => 100
- * )
- * )
+ * ]
+ * ]
*
* serverTemplate A server info associative array as documented for $wgDBservers.
* The host, hostName and load entries will be overridden.
*
* groupLoadsBySection A 3-d map giving server load ratios for each section and group.
* For example:
- * array(
- * 'section1' => array(
- * 'group1' => array(
+ * [
+ * 'section1' => [
+ * 'group1' => [
* 'db1' => 100,
* 'db2' => 100
- * )
- * )
- * )
+ * ]
+ * ]
+ * ]
*
* groupLoadsByDB A 3-d map giving server load ratios by DB name.
*
'servers' => $this->makeServerArray( $template, $loads, $groupLoads ),
'loadMonitor' => $this->loadMonitorClass,
'readOnlyReason' => $readOnlyReason,
- 'trxProfiler' => $this->trxProfiler
+ 'trxProfiler' => $this->trxProfiler,
+ 'srvCache' => $this->srvCache,
+ 'wanCache' => $this->wanCache
] );
}
* - servers : Required. Array of server info structures.
* - loadMonitor : Name of a class used to fetch server lag and load.
* - readOnlyReason : Reason the master DB is read-only if so [optional]
+ * - srvCache : BagOStuff object [optional]
+ * - wanCache : WANObjectCache object [optional]
* @throws MWException
*/
public function __construct( array $params ) {
}
}
- // Use APC/memcached style caching, but avoids loops with CACHE_DB (T141804)
- // @TODO: inject these in via LBFactory at some point
- $cache = ObjectCache::getLocalServerInstance();
- if ( $cache->getQoS( $cache::ATTR_EMULATION ) > $cache::QOS_EMULATION_SQL ) {
- $this->srvCache = $cache;
+ if ( isset( $params['srvCache'] ) ) {
+ $this->srvCache = $params['srvCache'];
} else {
$this->srvCache = new EmptyBagOStuff();
}
- $wCache = ObjectCache::getMainWANInstance();
- if ( $wCache->getQoS( $wCache::ATTR_EMULATION ) > $wCache::QOS_EMULATION_SQL ) {
- $this->wanCache = $wCache;
+ if ( isset( $params['wanCache'] ) ) {
+ $this->wanCache = $params['wanCache'];
} else {
$this->wanCache = WANObjectCache::newEmpty();
}
-
if ( isset( $params['trxProfiler'] ) ) {
$this->trxProfiler = $params['trxProfiler'];
} else {
/**
* This can happen in code like:
* foreach ( $dbs as $db ) {
- * $conn = $lb->getConnection( DB_SLAVE, array(), $db );
+ * $conn = $lb->getConnection( DB_SLAVE, [], $db );
* ...
* $lb->reuseConnection( $conn );
* }