MediaWiki REL1_33
LoadBalancerSingle.php
Go to the documentation of this file.
1<?php
24namespace Wikimedia\Rdbms;
25
26use InvalidArgumentException;
27
38 private $db;
39
44 public function __construct( array $params ) {
45 if ( !isset( $params['connection'] ) ) {
46 throw new InvalidArgumentException( "Missing 'connection' argument." );
47 }
48
49 $this->db = $params['connection'];
50
51 parent::__construct( [
52 'servers' => [
53 [
54 'type' => $this->db->getType(),
55 'host' => $this->db->getServer(),
56 'dbname' => $this->db->getDBname(),
57 'load' => 1,
58 ]
59 ],
60 'trxProfiler' => $params['trxProfiler'] ?? null,
61 'srvCache' => $params['srvCache'] ?? null,
62 'wanCache' => $params['wanCache'] ?? null,
63 'localDomain' => $params['localDomain'] ?? $this->db->getDomainID(),
64 'readOnlyReason' => $params['readOnlyReason'] ?? false,
65 ] );
66
67 if ( isset( $params['readOnlyReason'] ) ) {
68 $this->db->setLBInfo( 'readOnlyReason', $params['readOnlyReason'] );
69 }
70 }
71
78 public static function newFromConnection( IDatabase $db, array $params = [] ) {
79 return new static( array_merge(
80 [ 'localDomain' => $db->getDomainID() ],
81 $params,
82 [ 'connection' => $db ]
83 ) );
84 }
85
86 protected function reallyOpenConnection( array $server, DatabaseDomain $domain ) {
87 return $this->db;
88 }
89}
90
94class_alias( LoadBalancerSingle::class, 'LoadBalancerSingle' );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Class to handle database/prefix specification for IDatabase domains.
Trivial LoadBalancer that always returns an injected connection handle.
static newFromConnection(IDatabase $db, array $params=[])
reallyOpenConnection(array $server, DatabaseDomain $domain)
Open a new network connection to a server (uncached)
Database connection, tracking, load balancing, and transaction manager for a cluster.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
getDomainID()
Return the currently selected domain ID.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
$params