Skip to content

Commit

Permalink
Merge pull request #36 from PiR-B-/master
Browse files Browse the repository at this point in the history
Keep master connection
  • Loading branch information
mathroc committed Jan 27, 2016
2 parents 229a5a7 + af0ece9 commit 67f24db
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Driver/Connection/MasterSlavesConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ private function checkSlaves(array $slaves)

public function connectToMaster()
{
if ($this->currentConnectionParams === $this->master) {
return;
}
$this->currentConnectionParams = $this->master;
$this->currentSlave = null;
$this->wrappedConnection = null;
Expand Down Expand Up @@ -60,6 +63,9 @@ public function getCurrentConnection()

protected function wrap()
{
if ($this->wrappedConnection !== null) {
return $this->wrappedConnection;
}
if ($this->currentConnectionParams === null) {
$this->currentSlave = $this->chooseASlave();
$this->currentConnectionParams = $this->currentSlave ? $this->slaves[$this->currentSlave] : $this->master;
Expand Down

0 comments on commit 67f24db

Please sign in to comment.