Skip to content

Commit afaff53

Browse files
Try sentinels in round-robin without retries between each server.
1 parent e4f77b7 commit afaff53

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Cm/Cache/Backend/Redis.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,12 @@ public function __construct($options = array())
165165
$servers = preg_split('/\s*,\s*/', trim($options['server']), NULL, PREG_SPLIT_NO_EMPTY);
166166
$sentinel = NULL;
167167
$exception = NULL;
168+
for ($i = 0; $i <= $sentinelClientOptions->connectRetries; $i++) // Try each sentinel in round-robin fashion
168169
foreach ($servers as $server) {
169170
try {
170171
$sentinelClient = new Credis_Client($server, NULL, $sentinelClientOptions->timeout, $sentinelClientOptions->persistent);
171172
$sentinelClient->forceStandalone();
172-
$sentinelClient->setMaxConnectRetries($sentinelClientOptions->connectRetries);
173+
$sentinelClient->setMaxConnectRetries(0);
173174
if ($sentinelClientOptions->readTimeout) {
174175
$sentinelClient->setReadTimeout($sentinelClientOptions->readTimeout);
175176
}
@@ -199,8 +200,9 @@ public function __construct($options = array())
199200
}
200201

201202
$this->_redis = $redisMaster;
202-
break;
203+
break 2;
203204
} catch (Exception $e) {
205+
unset($sentinelClient);
204206
$exception = $e;
205207
}
206208
}

lib/Credis

0 commit comments

Comments
 (0)