Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/db/db_load_balancer.php
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Line(s) | |||||
* Returns connection index to slave database. This takes into account load ratios and lag times. | * Returns connection index to slave database. This takes into account load ratios and lag times. | ||||
* Side effect: opens connections to databases | * Side effect: opens connections to databases | ||||
* | * | ||||
* @return int | * @return int | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function getSlaveIndex() | protected function getSlaveIndex() | ||||
{ | { | ||||
if ( count($this->servers) == 1 || $this->Application->isAdmin ) { | if ( count($this->servers) == 1 || $this->Application->isAdmin || defined('CRON') ) { | ||||
// skip the load balancing if there's only one server OR in admin console | // Skip the load balancing if there's only one server OR in admin console OR in CRON. | ||||
return 0; | return 0; | ||||
} | } | ||||
elseif ( $this->slaveIndex !== false ) { | elseif ( $this->slaveIndex !== false ) { | ||||
// shortcut if generic reader exists already | // shortcut if generic reader exists already | ||||
return $this->slaveIndex; | return $this->slaveIndex; | ||||
} | } | ||||
$total_elapsed = 0; | $total_elapsed = 0; | ||||
▲ Show 20 Lines • Show All 682 Lines • Show Last 20 Lines |