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

Skip to content

Commit f97c843

Browse files
Integrating mobli's lazy connect and retry interval
1 parent 8443769 commit f97c843

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

redis_array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ PHP_METHOD(RedisArray, __construct)
270270
break;
271271

272272
case IS_ARRAY:
273-
ra = ra_make_array(Z_ARRVAL_P(z0), z_fun, z_dist, hPrev, b_index, l_retry_interval, b_pconnect TSRMLS_CC);
273+
ra = ra_make_array(Z_ARRVAL_P(z0), z_fun, z_dist, hPrev, b_index, l_retry_interval, b_pconnect, b_lazy_connect TSRMLS_CC);
274274
break;
275275

276276
default:

redis_array_impl.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ extern int le_redis_sock;
3030
extern zend_class_entry *redis_ce;
3131

3232
RedisArray*
33-
ra_load_hosts(RedisArray *ra, HashTable *hosts, long retry_interval, zend_bool lazy_connect TSRMLS_DC)
33+
ra_load_hosts(RedisArray *ra, HashTable *hosts, long retry_interval, zend_bool b_lazy_connect TSRMLS_DC)
3434
{
3535
int i, host_len, id;
3636
int count = zend_hash_num_elements(hosts);
3737
char *host, *p;
3838
short port;
39-
zval **zpData, *z_args, z_cons, z_ret;
39+
zval **zpData, z_cons, z_ret;
4040
RedisSock *redis_sock = NULL;
4141

4242
/* function calls on the Redis object */
@@ -70,9 +70,9 @@ ra_load_hosts(RedisArray *ra, HashTable *hosts, long retry_interval, zend_bool l
7070
call_user_function(&redis_ce->function_table, &ra->redis[i], &z_cons, &z_ret, 0, NULL TSRMLS_CC);
7171

7272
/* create socket */
73-
redis_sock = redis_sock_create(host, host_len, port, 0, ra->pconnect, NULL, retry_interval, lazy_connect);
73+
redis_sock = redis_sock_create(host, host_len, port, 0, ra->pconnect, NULL, retry_interval, b_lazy_connect);
7474

75-
if (!lazy_connect)
75+
if (!b_lazy_connect)
7676
{
7777
/* connect */
7878
redis_sock_server_open(redis_sock, 1 TSRMLS_CC);
@@ -269,7 +269,7 @@ RedisArray *ra_load_array(const char *name TSRMLS_DC) {
269269
}
270270

271271
/* create RedisArray object */
272-
ra = ra_make_array(hHosts, z_fun, z_dist, hPrev, b_index, l_retry_interval, b_pconnect, b_lazy_connect TSRMLS_CC);
272+
ra = ra_make_array(hHosts, z_fun, z_dist, hPrev, b_index, b_pconnect, l_retry_interval, b_lazy_connect TSRMLS_CC);
273273
ra->auto_rehash = b_autorehash;
274274

275275
/* cleanup */
@@ -294,7 +294,7 @@ RedisArray *ra_load_array(const char *name TSRMLS_DC) {
294294
}
295295

296296
RedisArray *
297-
ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev, zend_bool b_index, long retry_interval, zend_bool b_pconnect, zend_bool b_lazy_connect TSRMLS_DC) {
297+
ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev, zend_bool b_index, zend_bool b_pconnect, long retry_interval, zend_bool b_lazy_connect TSRMLS_DC) {
298298

299299
int count = zend_hash_num_elements(hosts);
300300

@@ -312,10 +312,10 @@ ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev
312312
/* init array data structures */
313313
ra_init_function_table(ra);
314314

315-
if(NULL == ra_load_hosts(ra, hosts, retry_interval, lazy_connect TSRMLS_CC)) {
315+
if(NULL == ra_load_hosts(ra, hosts, retry_interval, b_lazy_connect TSRMLS_CC)) {
316316
return NULL;
317317
}
318-
ra->prev = hosts_prev ? ra_make_array(hosts_prev, z_fun, z_dist, NULL, b_index, retry_interval, b_pconnect, b_lazy_connect TSRMLS_CC) : NULL;
318+
ra->prev = hosts_prev ? ra_make_array(hosts_prev, z_fun, z_dist, NULL, b_index, b_pconnect, retry_interval, b_lazy_connect TSRMLS_CC) : NULL;
319319

320320
/* copy function if provided */
321321
if(z_fun) {

redis_array_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include "common.h"
66
#include "redis_array.h"
77

8-
RedisArray *ra_load_hosts(RedisArray *ra, HashTable *hosts, long retry_interval, zend_bool lazy_connect TSRMLS_DC);
8+
RedisArray *ra_load_hosts(RedisArray *ra, HashTable *hosts, long retry_interval, zend_bool b_lazy_connect TSRMLS_DC);
99
RedisArray *ra_load_array(const char *name TSRMLS_DC);
10-
RedisArray *ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev, zend_bool b_index, long retry_interval, zend_bool b_pconnect, zend_bool b_lazy_connect TSRMLS_DC);
10+
RedisArray *ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev, zend_bool b_index, zend_bool b_pconnect, long retry_interval, zend_bool b_lazy_connect TSRMLS_DC);
1111
zval *ra_find_node_by_name(RedisArray *ra, const char *host, int host_len TSRMLS_DC);
1212
zval *ra_find_node(RedisArray *ra, const char *key, int key_len, int *out_pos TSRMLS_DC);
1313
void ra_init_function_table(RedisArray *ra);

0 commit comments

Comments
 (0)