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:
authormichael-grunder <michael.grunder@gmail.com>2019-02-19 07:00:08 +0300
committermichael-grunder <michael.grunder@gmail.com>2019-02-19 07:00:08 +0300
commitf89e941a8891ede511b1bac80fd13d0af4d58a71 (patch)
treeee6aee700d778e48c4200d18035e0c698c2227b1 /redis.c
parent46f035615ecaf839cfe515dac39f209d50689461 (diff)
Change ZPOP* return type and implement blocking variants
This commit updates ZPOPMIN/ZPOPMAX to return the same format that zRange WITHSCORES and zRangeByScore WITHSCORES does. In addition the blocking variants BZPOPMIN and BZPOPMAX are implemented.
Diffstat (limited to 'redis.c')
-rw-r--r--redis.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/redis.c b/redis.c
index bb9f4203..52924b1b 100644
--- a/redis.c
+++ b/redis.c
@@ -259,6 +259,8 @@ static zend_function_entry redis_functions[] = {
PHP_ME(Redis, blPop, arginfo_blrpop, ZEND_ACC_PUBLIC)
PHP_ME(Redis, brPop, arginfo_blrpop, ZEND_ACC_PUBLIC)
PHP_ME(Redis, brpoplpush, arginfo_brpoplpush, ZEND_ACC_PUBLIC)
+ PHP_ME(Redis, bzPopMax, arginfo_blrpop, ZEND_ACC_PUBLIC)
+ PHP_ME(Redis, bzPopMin, arginfo_blrpop, ZEND_ACC_PUBLIC)
PHP_ME(Redis, clearLastError, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Redis, client, arginfo_client, ZEND_ACC_PUBLIC)
PHP_ME(Redis, close, arginfo_void, ZEND_ACC_PUBLIC)
@@ -1376,14 +1378,14 @@ PHP_METHOD(Redis, rPop)
/* {{{ proto string Redis::blPop(string key1, string key2, ..., int timeout) */
PHP_METHOD(Redis, blPop)
{
- REDIS_PROCESS_CMD(blpop, redis_sock_read_multibulk_reply);
+ REDIS_PROCESS_KW_CMD("BLPOP", redis_varkey_timeout_cmd, redis_sock_read_multibulk_reply);
}
/* }}} */
/* {{{ proto string Redis::brPop(string key1, string key2, ..., int timeout) */
PHP_METHOD(Redis, brPop)
{
- REDIS_PROCESS_CMD(brpop, redis_sock_read_multibulk_reply);
+ REDIS_PROCESS_KW_CMD("BRPOP", redis_varkey_timeout_cmd, redis_sock_read_multibulk_reply);
}
/* }}} */
@@ -2144,9 +2146,9 @@ PHP_METHOD(Redis, zUnion) {
PHP_METHOD(Redis, zPopMax)
{
if (ZEND_NUM_ARGS() == 1) {
- REDIS_PROCESS_KW_CMD("ZPOPMAX", redis_key_cmd, redis_sock_read_multibulk_reply);
+ REDIS_PROCESS_KW_CMD("ZPOPMAX", redis_key_cmd, redis_mbulk_reply_zipped_keys_dbl);
} else if (ZEND_NUM_ARGS() == 2) {
- REDIS_PROCESS_KW_CMD("ZPOPMAX", redis_key_long_cmd, redis_sock_read_multibulk_reply);
+ REDIS_PROCESS_KW_CMD("ZPOPMAX", redis_key_long_cmd, redis_mbulk_reply_zipped_keys_dbl);
} else {
ZEND_WRONG_PARAM_COUNT();
}
@@ -2157,15 +2159,27 @@ PHP_METHOD(Redis, zPopMax)
PHP_METHOD(Redis, zPopMin)
{
if (ZEND_NUM_ARGS() == 1) {
- REDIS_PROCESS_KW_CMD("ZPOPMIN", redis_key_cmd, redis_sock_read_multibulk_reply);
+ REDIS_PROCESS_KW_CMD("ZPOPMIN", redis_key_cmd, redis_mbulk_reply_zipped_keys_dbl);
} else if (ZEND_NUM_ARGS() == 2) {
- REDIS_PROCESS_KW_CMD("ZPOPMIN", redis_key_long_cmd, redis_sock_read_multibulk_reply);
+ REDIS_PROCESS_KW_CMD("ZPOPMIN", redis_key_long_cmd, redis_mbulk_reply_zipped_keys_dbl);
} else {
ZEND_WRONG_PARAM_COUNT();
}
}
/* }}} */
+/* {{{ proto Redis::bzPopMax(Array(keys) [, timeout]): Array */
+PHP_METHOD(Redis, bzPopMax) {
+ REDIS_PROCESS_KW_CMD("BZPOPMAX", redis_varkey_timeout_cmd, redis_sock_read_multibulk_reply);
+}
+/* }}} */
+
+/* {{{ proto Redis::bzPopMin(Array(keys) [, timeout]): Array */
+PHP_METHOD(Redis, bzPopMin) {
+ REDIS_PROCESS_KW_CMD("BZPOPMIN", redis_varkey_timeout_cmd, redis_sock_read_multibulk_reply);
+}
+/* }}} */
+
/* hashes */
/* {{{ proto long Redis::hset(string key, string mem, string val) */