Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cluster_library.h4
-rw-r--r--redis_cluster.c34
-rw-r--r--redis_cluster.h1
3 files changed, 33 insertions, 6 deletions
diff --git a/cluster_library.h b/cluster_library.h
index 26df6b2e..26b7406f 100644
--- a/cluster_library.h
+++ b/cluster_library.h
@@ -13,8 +13,8 @@
/* Minimum valid CLUSTER NODES line element count
and the minimum we expect if there are slots */
-#define CLUSTER_MIN_NODE_LINE 8
-#define CLUSTER_MIN_SLOTS_COUNT 9
+#define CLUSTER_MIN_NODE_LINE 8
+#define CLUSTER_MIN_SLOTS_COUNT 9
/* Length of a cluster name */
#define CLUSTER_NAME_LEN 40
diff --git a/redis_cluster.c b/redis_cluster.c
index 18baa155..5bc83e2a 100644
--- a/redis_cluster.c
+++ b/redis_cluster.c
@@ -177,7 +177,8 @@ zend_function_entry redis_cluster_functions[] = {
PHP_ME(RedisCluster, _prefix, NULL, ZEND_ACC_PUBLIC)
PHP_ME(RedisCluster, _serialize, NULL, ZEND_ACC_PUBLIC)
PHP_ME(RedisCluster, _unserialize, NULL, ZEND_ACC_PUBLIC)
-
+ PHP_ME(RedisCluster, _masters, NULL, ZEND_ACC_PUBLIC)
+
PHP_ME(RedisCluster, multi, NULL, ZEND_ACC_PUBLIC)
PHP_ME(RedisCluster, exec, NULL, ZEND_ACC_PUBLIC)
PHP_ME(RedisCluster, discard, NULL, ZEND_ACC_PUBLIC)
@@ -1670,6 +1671,30 @@ PHP_METHOD(RedisCluster, _unserialize) {
}
/* }}} */
+/* {{{ proto array RedisCluster::_masters() */
+PHP_METHOD(RedisCluster, _masters) {
+ redisCluster *c = GET_CONTEXT();
+ zval *z_ret;
+ redisClusterNode **node;
+ char buf[1024];
+ size_t len;
+
+ MAKE_STD_ZVAL(z_ret);
+ array_init(z_ret);
+
+ for(zend_hash_internal_pointer_reset(c->nodes);
+ zend_hash_get_current_data(c->nodes, (void**)&node)==SUCCESS;
+ zend_hash_move_forward(c->nodes))
+ {
+ len = snprintf(buf, sizeof(buf), "%s:%d", (*node)->sock->host,
+ (*node)->sock->port);
+ add_next_index_stringl(z_ret, buf, (int)len, 1);
+ }
+
+ *return_value = *z_ret;
+ efree(z_ret);
+}
+
/*
* Transaction handling
*/
@@ -1940,9 +1965,9 @@ static void cluster_kscan_cmd(INTERNAL_FUNCTION_PARAMETERS,
RETURN_FALSE;
}
- // Requires a key
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/|s!l", &key, &key_len,
- &z_it, &pat, &pat_len, &count)==FAILURE)
+ /* Parse arguments */
+ if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/|s!l", &key,
+ &key_len, &z_it, &pat, &pat_len, &count)==FAILURE)
{
RETURN_FALSE;
}
@@ -2007,6 +2032,7 @@ static void cluster_kscan_cmd(INTERNAL_FUNCTION_PARAMETERS,
/* {{{ proto RedisCluster::scan(long it [, string pat, long count]) */
PHP_METHOD(RedisCluster, scan) {
+
}
/* {{{ proto RedisCluster::sscan(string key, long it [string pat, long cnt]) */
diff --git a/redis_cluster.h b/redis_cluster.h
index 66c4c35c..9c9fba45 100644
--- a/redis_cluster.h
+++ b/redis_cluster.h
@@ -251,5 +251,6 @@ PHP_METHOD(RedisCluster, setoption);
PHP_METHOD(RedisCluster, _prefix);
PHP_METHOD(RedisCluster, _serialize);
PHP_METHOD(RedisCluster, _unserialize);
+PHP_METHOD(RedisCluster, _masters);
#endif