Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17600dd

Browse files
WIP: Enable pooling for cluster slave nodes.
Connections are stashed via redis_sock_disconnect so if RedisCluster doesn't explicitly call that for slaves then pooling is never used for those connections. Addresses #1568
1 parent 68c8382 commit 17600dd

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cluster_library.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,11 +1256,19 @@ static int cluster_check_response(redisCluster *c, REDIS_REPLY_TYPE *reply_type
12561256

12571257
/* Disconnect from each node we're connected to */
12581258
PHP_REDIS_API void cluster_disconnect(redisCluster *c, int force TSRMLS_DC) {
1259-
redisClusterNode *node;
1259+
redisClusterNode *node, *slave;
12601260

12611261
ZEND_HASH_FOREACH_PTR(c->nodes, node) {
12621262
if (node == NULL) continue;
1263+
1264+
/* Disconnect from the master */
12631265
redis_sock_disconnect(node->sock, force TSRMLS_CC);
1266+
1267+
/* We also want to disconnect any slave connections so they will be pooled
1268+
* in the event we are using persistent connections and connection pooling. */
1269+
ZEND_HASH_FOREACH_PTR(node->slaves, slave) {
1270+
redis_sock_disconnect(slave->sock, force TSRMLS_CC);
1271+
} ZEND_HASH_FOREACH_END();
12641272
} ZEND_HASH_FOREACH_END();
12651273
}
12661274

0 commit comments

Comments
 (0)