Skip to content

Commit

Permalink
Swith to master before fetching info for predis with replicated conne…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
yatsukhnenko committed Sep 27, 2024
1 parent f76253c commit 8e4508c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions includes/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -1147,9 +1147,14 @@ public function fetch_info() {
$info = $this->is_predis()
? $this->redis->getClientBy( 'id', $connectionId )->info()
: $this->redis->info( $connectionId );
} else if ($this->is_predis() && $this->redis->getConnection() instanceof Predis\Connection\Replication\ReplicationInterface) {
$info = $this->redis->getMaster()->info();
} else {
if ( $this->is_predis() ) {
$connection = $this->redis->getConnection();
if ( $connection instanceof Predis\Connection\Replication\ReplicationInterface ) {
$connection->switchToMaster();
}
}

$info = $this->redis->info();
}

Expand Down

0 comments on commit 8e4508c

Please sign in to comment.