diff options
-rw-r--r-- | cluster_library.c | 2 | ||||
-rw-r--r-- | php_redis.h | 1 | ||||
-rw-r--r-- | redis.c | 7 | ||||
-rw-r--r-- | redis_cluster.c | 7 | ||||
-rw-r--r-- | redis_cluster.h | 1 | ||||
-rw-r--r-- | redis_commands.c | 39 | ||||
-rw-r--r-- | redis_commands.h | 3 |
7 files changed, 59 insertions, 1 deletions
diff --git a/cluster_library.c b/cluster_library.c index e4354fc3..81d807b0 100644 --- a/cluster_library.c +++ b/cluster_library.c @@ -1802,7 +1802,7 @@ PHPAPI void cluster_info_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, void *ctx) { zval *z_result; - char *info, *p; + char *info; // Read our bulk response if((info = redis_sock_read_bulk_reply(SLOT_SOCK(c,c->reply_slot), diff --git a/php_redis.h b/php_redis.h index 96a0f390..8b31af5d 100644 --- a/php_redis.h +++ b/php_redis.h @@ -116,6 +116,7 @@ PHP_METHOD(Redis, zRangeByScore); PHP_METHOD(Redis, zRangeByLex); PHP_METHOD(Redis, zRevRangeByScore); PHP_METHOD(Redis, zRangeByLex); +PHP_METHOD(Redis, zLexCount); PHP_METHOD(Redis, zCount); PHP_METHOD(Redis, zDeleteRangeByScore); PHP_METHOD(Redis, zDeleteRangeByRank); @@ -197,6 +197,7 @@ static zend_function_entry redis_functions[] = { PHP_ME(Redis, zRangeByScore, NULL, ZEND_ACC_PUBLIC) PHP_ME(Redis, zRevRangeByScore, NULL, ZEND_ACC_PUBLIC) PHP_ME(Redis, zRangeByLex, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Redis, zLexCount, NULL, ZEND_ACC_PUBLIC) PHP_ME(Redis, zCount, NULL, ZEND_ACC_PUBLIC) PHP_ME(Redis, zDeleteRangeByScore, NULL, ZEND_ACC_PUBLIC) PHP_ME(Redis, zDeleteRangeByRank, NULL, ZEND_ACC_PUBLIC) @@ -2010,6 +2011,12 @@ PHP_METHOD(Redis, zRangeByLex) { } /* }}} */ +/* {{{ proto long Redis::zLexCount(string key, string min, string max) */ +PHP_METHOD(Redis, zLexCount) { + REDIS_PROCESS_CMD(zlexcount, redis_long_response); +} +/* }}} */ + /* {{{ proto long Redis::zDelete(string key, string member) */ PHP_METHOD(Redis, zDelete) { diff --git a/redis_cluster.c b/redis_cluster.c index 13d88471..611559fe 100644 --- a/redis_cluster.c +++ b/redis_cluster.c @@ -156,6 +156,7 @@ zend_function_entry redis_cluster_functions[] = { PHP_ME(RedisCluster, zrangebyscore, NULL, ZEND_ACC_PUBLIC) PHP_ME(RedisCluster, zrevrangebyscore, NULL, ZEND_ACC_PUBLIC) PHP_ME(RedisCluster, zrangebylex, NULL, ZEND_ACC_PUBLIC) + PHP_ME(RedisCluster, zlexcount, NULL, ZEND_ACC_PUBLIC) PHP_ME(RedisCluster, zunionstore, NULL, ZEND_ACC_PUBLIC) PHP_ME(RedisCluster, zinterstore, NULL, ZEND_ACC_PUBLIC) PHP_ME(RedisCluster, zrem, NULL, ZEND_ACC_PUBLIC) @@ -1418,6 +1419,12 @@ PHP_METHOD(RedisCluster, zrangebylex) { } /* }}} */ +/* {{{ proto RedisCluster::zlexcount(string key, string min, string max) */ +PHP_METHOD(RedisCluster, zlexcount) { + CLUSTER_PROCESS_CMD(zlexcount, cluster_long_resp); +} +/* }}} */ + /* {{{ proto RedisCluster::sort(string key, array options) */ PHP_METHOD(RedisCluster, sort) { redisCluster *c = GET_CONTEXT(); diff --git a/redis_cluster.h b/redis_cluster.h index 36228df0..593e6877 100644 --- a/redis_cluster.h +++ b/redis_cluster.h @@ -214,6 +214,7 @@ PHP_METHOD(RedisCluster, zrevrange); PHP_METHOD(RedisCluster, zrangebyscore); PHP_METHOD(RedisCluster, zrevrangebyscore); PHP_METHOD(RedisCluster, zrangebylex); +PHP_METHOD(RedisCluster, zlexcount); PHP_METHOD(RedisCluster, zunionstore); PHP_METHOD(RedisCluster, zinterstore); PHP_METHOD(RedisCluster, sort); diff --git a/redis_commands.c b/redis_commands.c index 48692f89..3c4687a7 100644 --- a/redis_commands.c +++ b/redis_commands.c @@ -2452,6 +2452,45 @@ int redis_zrangebylex_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, return SUCCESS; } +/* ZLEXCOUNT */ +int redis_zlexcount_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx) +{ + char *key, *min, *max; + int key_len, min_len, max_len, key_free; + + /* Parse args */ + if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &key, &key_len, + &min, &min_len, &max, &max_len)==FAILURE) + { + return FAILURE; + } + + /* Quick sanity check on min/max */ + if(min_len<1 || max_len<1 || (min[0]!='(' && min[0]!='[') || + (max[0]!='(' && max[0]!='[')) + { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "Min and Max arguments must begin with '(' or '['"); + return FAILURE; + } + + /* Prefix key if we need to */ + key_free = redis_key_prefix(redis_sock, &key, &key_len); + + /* Construct command */ + *cmd_len = redis_cmd_format_static(cmd, "ZLEXCOUNT", "sss", key, key_len, + min, min_len, max, max_len); + + /* set slot */ + CMD_SET_SLOT(slot,key,key_len); + + /* Free key if prefixed */ + if(key_free) efree(key); + + return SUCCESS; +} + /* * Redis commands that don't deal with the server at all. The RedisSock* * pointer is the only thing retreived differently, so we just take that diff --git a/redis_commands.h b/redis_commands.h index 08763c23..3451a63c 100644 --- a/redis_commands.h +++ b/redis_commands.h @@ -200,6 +200,9 @@ int redis_sdiffstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, int redis_zrangebylex_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, char **cmd, int *cmd_len, short *slot, void **ctx); +int redis_zlexcount_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + int redis_fmt_scan_cmd(char **cmd, REDIS_SCAN_TYPE type, char *key, int key_len, long it, char *pat, int pat_len, long count); |