Skip to content

Commit a1be927

Browse files
committed
Fix Predis cluster flush
1 parent 00bd8a2 commit a1be927

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

includes/class-predis.php

+8-9
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,10 @@ public function connect( $read_timeout = null ) {
139139
* @return bool
140140
*/
141141
public function flush( $throw_exception = false ) {
142-
$flush_timeout = defined( 'WP_REDIS_FLUSH_TIMEOUT' )
143-
? intval( WP_REDIS_FLUSH_TIMEOUT )
144-
: 5;
145-
146142
if ( is_null( $this->redis ) ) {
143+
$flush_timeout = defined( 'WP_REDIS_FLUSH_TIMEOUT' )
144+
? intval( WP_REDIS_FLUSH_TIMEOUT )
145+
: 5;
147146
try {
148147
$this->connect( $flush_timeout );
149148
} catch ( Exception $exception ) {
@@ -153,16 +152,16 @@ public function flush( $throw_exception = false ) {
153152

154153
return false;
155154
}
156-
}
157155

158-
if ( is_null( $this->redis ) ) {
159-
return false;
156+
if ( is_null( $this->redis ) ) {
157+
return false;
158+
}
160159
}
161160

162161
if ( defined( 'WP_REDIS_CLUSTER' ) ) {
163162
try {
164-
foreach ( $this->redis->_masters() as $master ) {
165-
$this->redis->flushdb( $master );
163+
foreach ( $this->redis->getIterator() as $master ) {
164+
$master->flushdb();
166165
}
167166
} catch ( Exception $exception ) {
168167
if ( $throw_exception ) {

0 commit comments

Comments
 (0)