diff options
-rw-r--r-- | cluster_library.c | 18 | ||||
-rw-r--r-- | cluster_library.h | 2 | ||||
-rw-r--r-- | library.c | 2 | ||||
-rw-r--r-- | library.h | 2 | ||||
-rw-r--r-- | redis_cluster.c | 2 |
5 files changed, 24 insertions, 2 deletions
diff --git a/cluster_library.c b/cluster_library.c index dd1e0bbc..2e926963 100644 --- a/cluster_library.c +++ b/cluster_library.c @@ -2314,6 +2314,24 @@ cluster_xclaim_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, void *ctx) { } +/* XINFO */ +PHP_REDIS_API void +cluster_xinfo_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, void *ctx) +{ + zval z_ret; + + array_init(&z_ret); + if (redis_read_xinfo_response(c->cmd_sock, &z_ret, c->reply_len) != SUCCESS) { + zval_dtor(&z_ret); + CLUSTER_RETURN_FALSE(c); + } + + if (CLUSTER_IS_ATOMIC(c)) { + RETURN_ZVAL(&z_ret, 0, 1); + } + add_next_index_zval(&c->multi_resp, &z_ret); +} + /* MULTI BULK response loop where we might pull the next one */ PHP_REDIS_API zval *cluster_zval_mbulk_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, int pull, mbulk_cb cb, zval *z_ret) diff --git a/cluster_library.h b/cluster_library.h index 3b3b4a7d..df83d967 100644 --- a/cluster_library.h +++ b/cluster_library.h @@ -487,6 +487,8 @@ PHP_REDIS_API void cluster_xrange_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, void *ctx); PHP_REDIS_API void cluster_xclaim_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, void *ctx); +PHP_REDIS_API void cluster_xinfo_resp(INTERNAL_FUNCTION_PARAMETERS, + redisCluster *c, void *ctx); /* MULTI BULK processing callbacks */ int mbulk_resp_loop(RedisSock *redis_sock, zval *z_result, @@ -1451,7 +1451,7 @@ failure: return -1; } -static int +PHP_REDIS_API int redis_read_xinfo_response(RedisSock *redis_sock, zval *z_ret, int elements) { zval zv; @@ -109,6 +109,8 @@ PHP_REDIS_API int redis_read_stream_messages_multi(RedisSock *redis_sock, int count, zval *z_ret TSRMLS_DC); PHP_REDIS_API int redis_read_xclaim_response(RedisSock *redis_sock, int count, zval *rv TSRMLS_DC); +PHP_REDIS_API int +redis_read_xinfo_response(RedisSock *redis_sock, zval *z_ret, int elements TSRMLS_DC); /* * Variant Read methods, mostly to implement eval diff --git a/redis_cluster.c b/redis_cluster.c index 0342096c..591138f6 100644 --- a/redis_cluster.c +++ b/redis_cluster.c @@ -3095,7 +3095,7 @@ PHP_METHOD(RedisCluster, xgroup) { /* {{{ proto variant RedisCluster::xinfo(string op, [string arg1, string arg2]); */ PHP_METHOD(RedisCluster, xinfo) { - CLUSTER_PROCESS_CMD(xinfo, cluster_variant_resp, 0); + CLUSTER_PROCESS_CMD(xinfo, cluster_xinfo_resp, 0); } /* {{{ proto string RedisCluster::xlen(string key) }}} */ |