MediaWiki REL1_33
DBAccessBase.php
Go to the documentation of this file.
1<?php
2
6
34abstract class DBAccessBase implements IDBAccessObject {
39 protected $wiki = false;
40
45 public function __construct( $wiki = false ) {
46 $this->wiki = $wiki;
47 }
48
62 protected function getConnection( $id, array $groups = [] ) {
63 $loadBalancer = $this->getLoadBalancer();
64
65 return $loadBalancer->getConnection( $id, $groups, $this->wiki );
66 }
67
77 protected function releaseConnection( IDatabase $db ) {
78 if ( $this->wiki !== false ) {
79 $loadBalancer = $this->getLoadBalancer();
80 $loadBalancer->reuseConnection( $db );
81 }
82 }
83
93 public function getLoadBalancer() {
94 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
95 return $lbFactory->getMainLB( $this->wiki );
96 }
97}
getLoadBalancer()
Get the database type used for read operations.
__construct( $wiki=false)
getConnection( $id, array $groups=[])
Returns a database connection.
releaseConnection(IDatabase $db)
Releases a database connection and makes it available for recycling.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Database connection, tracking, load balancing, and transaction manager for a cluster.
Interface for database access objects.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
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))