Skip to content

Commit

Permalink
Fetch Redis server info for replicated connections
Browse files Browse the repository at this point in the history
  • Loading branch information
yatsukhnenko committed May 6, 2024
1 parent 2900a52 commit 5f9ab1a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions includes/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -1139,24 +1139,18 @@ protected function connect_using_hhvm( $parameters ) {
* @return void
*/
public function fetch_info() {
$options = method_exists( $this->redis, 'getOptions' )
? $this->redis->getOptions()
: new stdClass();

if ( isset( $options->replication ) && $options->replication ) {
return;
}

if ( defined( 'WP_REDIS_CLUSTER' ) ) {
$connectionId = is_string( WP_REDIS_CLUSTER )
? 'SERVER'
: current( $this->build_cluster_connection_array() );

$info = $this->determine_client() === 'predis'
$info = $this->is_predis()
? $this->redis->getClientBy( 'id', $connectionId )->info()
: $this->redis->info( $connectionId );
} else {
$info = $this->redis->info();
$info = $this->is_predis() && $this->redis->getConnection() instanceof Predis\Connection\Replication\MasterSlaveReplication
? $this->redis->getClientBy( 'role' , 'master' )->info()
: $this->redis->info();
}

if ( isset( $info['redis_version'] ) ) {
Expand Down

0 comments on commit 5f9ab1a

Please sign in to comment.