diff options
author | michael-grunder <michael.grunder@gmail.com> | 2013-08-11 19:54:59 +0400 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2013-08-11 19:54:59 +0400 |
commit | dcbeae7599ccc1fe0310d67ba29629c3774084d5 (patch) | |
tree | 444a61ff03fcce99de974dfb2dfa045884cea65e /redis_array_impl.c | |
parent | 2099f1904ad7b1b07375bb942bfb0dc19aae19bc (diff) |
Persistent connections with RedisArray
Re-integrating the now old ra-performance branch into a git-flow
branch. I could have merged it but this was easier with so few
changes
Diffstat (limited to 'redis_array_impl.c')
-rw-r--r-- | redis_array_impl.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/redis_array_impl.c b/redis_array_impl.c index bafcbd49..9b6f00bf 100644 --- a/redis_array_impl.c +++ b/redis_array_impl.c @@ -160,9 +160,10 @@ RedisArray *ra_load_array(const char *name TSRMLS_DC) { zval *z_params_index; zval *z_params_autorehash; zval *z_params_retry_interval; + zval *z_params_pconnect; RedisArray *ra = NULL; - zend_bool b_index = 0, b_autorehash = 0; + zend_bool b_index = 0, b_autorehash = 0, b_pconnect = 0; long l_retry_interval = 0; HashTable *hHosts = NULL, *hPrev = NULL; @@ -241,8 +242,18 @@ RedisArray *ra_load_array(const char *name TSRMLS_DC) { } } + /* find pconnect option */ + MAKE_STD_ZVAL(z_params_pconnect); + array_init(z_params_pconnect); + sapi_module.treat_data(PARSE_STRING, estrdup(INI_STR("redis.arrays.pconnect")), z_params_pconnect TSRMLS_CC); + if (zend_hash_find(Z_ARRVAL_P(z_params_pconnect), name, strlen(name) + 1, (void**) &z_data_pp) != FAILURE) { + if(Z_TYPE_PP(z_data_pp) == IS_STRING && strncmp(Z_STRVAL_PP(z_data_pp), "1", 1) == 0) { + b_pconnect = 1; + } + } + /* create RedisArray object */ - ra = ra_make_array(hHosts, z_fun, z_dist, hPrev, b_index, l_retry_interval TSRMLS_CC); + ra = ra_make_array(hHosts, z_fun, z_dist, hPrev, b_index, l_retry_interval, b_pconnect TSRMLS_CC); ra->auto_rehash = b_autorehash; /* cleanup */ @@ -258,12 +269,14 @@ RedisArray *ra_load_array(const char *name TSRMLS_DC) { efree(z_params_autorehash); zval_dtor(z_params_retry_interval); efree(z_params_retry_interval); + zval_dtor(z_params_pconnect); + efree(z_params_pconnect); return ra; } RedisArray * -ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev, zend_bool b_index, long retry_interval TSRMLS_DC) { +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 TSRMLS_DC) { int count = zend_hash_num_elements(hosts); @@ -284,7 +297,7 @@ ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev if(NULL == ra_load_hosts(ra, hosts, retry_interval TSRMLS_CC)) { return NULL; } - ra->prev = hosts_prev ? ra_make_array(hosts_prev, z_fun, z_dist, NULL, b_index, retry_interval TSRMLS_CC) : NULL; + ra->prev = hosts_prev ? ra_make_array(hosts_prev, z_fun, z_dist, NULL, b_index, retry_interval, b_pconnect TSRMLS_CC) : NULL; /* copy function if provided */ if(z_fun) { |