diff options
author | Pavlo Yatsukhnenko <yatsukhnenko@gmail.com> | 2019-01-03 17:08:09 +0300 |
---|---|---|
committer | Pavlo Yatsukhnenko <yatsukhnenko@gmail.com> | 2019-01-03 17:17:20 +0300 |
commit | 850027ffd36ce224846d142fd3fb5344f08aef16 (patch) | |
tree | 34d8e9aec88bf4b770c6a19e8f5dbc8b80f43895 /redis_array.c | |
parent | 71922bf1dd30af17cf2939b1c5e9b33f7fe2a5c4 (diff) |
Different key hashing algorithms from hash extension.
Diffstat (limited to 'redis_array.c')
-rw-r--r-- | redis_array.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/redis_array.c b/redis_array.c index e4c62b48..79cf0804 100644 --- a/redis_array.c +++ b/redis_array.c @@ -159,6 +159,9 @@ redis_array_free(RedisArray *ra) /* Distributor */ zval_dtor(&ra->z_dist); + /* Hashing algorithm */ + zval_dtor(&ra->z_algo); + /* Delete pur commands */ zend_hash_destroy(ra->pure_cmds); FREE_HASHTABLE(ra->pure_cmds); @@ -269,7 +272,7 @@ redis_array_get(zval *id TSRMLS_DC) Public constructor */ PHP_METHOD(RedisArray, __construct) { - zval *z0, z_fun, z_dist, *zpData, *z_opts = NULL; + zval *z0, z_fun, z_dist, z_algo, *zpData, *z_opts = NULL; RedisArray *ra = NULL; zend_bool b_index = 0, b_autorehash = 0, b_pconnect = 0, consistent = 0; HashTable *hPrev = NULL, *hOpts = NULL; @@ -284,6 +287,7 @@ PHP_METHOD(RedisArray, __construct) ZVAL_NULL(&z_fun); ZVAL_NULL(&z_dist); + ZVAL_NULL(&z_algo); /* extract options */ if(z_opts) { hOpts = Z_ARRVAL_P(z_opts); @@ -306,6 +310,11 @@ PHP_METHOD(RedisArray, __construct) ZVAL_ZVAL(&z_dist, zpData, 1, 0); } + /* extract function name. */ + if ((zpData = zend_hash_str_find(hOpts, "algorithm", sizeof("algorithm") - 1)) != NULL && Z_TYPE_P(zpData) == IS_STRING) { + ZVAL_ZVAL(&z_algo, zpData, 1, 0); + } + /* extract index option. */ if ((zpData = zend_hash_str_find(hOpts, "index", sizeof("index") - 1)) != NULL) { b_index = zval_is_true(zpData); @@ -370,12 +379,13 @@ PHP_METHOD(RedisArray, __construct) break; case IS_ARRAY: - ra = ra_make_array(Z_ARRVAL_P(z0), &z_fun, &z_dist, hPrev, b_index, b_pconnect, l_retry_interval, b_lazy_connect, d_connect_timeout, read_timeout, consistent TSRMLS_CC); + ra = ra_make_array(Z_ARRVAL_P(z0), &z_fun, &z_dist, &z_algo, hPrev, b_index, b_pconnect, l_retry_interval, b_lazy_connect, d_connect_timeout, read_timeout, consistent TSRMLS_CC); break; default: WRONG_PARAM_COUNT; } + zval_dtor(&z_algo); zval_dtor(&z_dist); zval_dtor(&z_fun); |