mirror of
https://github.com/fluencelabs/redis
synced 2025-04-15 05:36:03 +00:00
ZADD RETCH option renamed CH
From Twitter: "@antirez that’s an awfully-named command :( http://en.wikipedia.org/wiki/Retching"
This commit is contained in:
parent
23ba5c1092
commit
d8a8dca7fd
@ -1175,7 +1175,7 @@ void zsetConvert(robj *zobj, int encoding) {
|
|||||||
#define ZADD_INCR (1<<0) /* Increment the score instead of setting it. */
|
#define ZADD_INCR (1<<0) /* Increment the score instead of setting it. */
|
||||||
#define ZADD_NX (1<<1) /* Don't touch elements not already existing. */
|
#define ZADD_NX (1<<1) /* Don't touch elements not already existing. */
|
||||||
#define ZADD_XX (1<<2) /* Only touch elements already exisitng. */
|
#define ZADD_XX (1<<2) /* Only touch elements already exisitng. */
|
||||||
#define ZADD_RETCH (1<<3) /* Return the number of elements added or updated.*/
|
#define ZADD_CH (1<<3) /* Return num of elements added or updated. */
|
||||||
void zaddGenericCommand(redisClient *c, int flags) {
|
void zaddGenericCommand(redisClient *c, int flags) {
|
||||||
static char *nanerr = "resulting score is not a number (NaN)";
|
static char *nanerr = "resulting score is not a number (NaN)";
|
||||||
robj *key = c->argv[1];
|
robj *key = c->argv[1];
|
||||||
@ -1200,7 +1200,7 @@ void zaddGenericCommand(redisClient *c, int flags) {
|
|||||||
char *opt = c->argv[scoreidx]->ptr;
|
char *opt = c->argv[scoreidx]->ptr;
|
||||||
if (!strcasecmp(opt,"nx")) flags |= ZADD_NX;
|
if (!strcasecmp(opt,"nx")) flags |= ZADD_NX;
|
||||||
else if (!strcasecmp(opt,"xx")) flags |= ZADD_XX;
|
else if (!strcasecmp(opt,"xx")) flags |= ZADD_XX;
|
||||||
else if (!strcasecmp(opt,"retch")) flags |= ZADD_RETCH;
|
else if (!strcasecmp(opt,"ch")) flags |= ZADD_CH;
|
||||||
else if (!strcasecmp(opt,"incr")) flags |= ZADD_INCR;
|
else if (!strcasecmp(opt,"incr")) flags |= ZADD_INCR;
|
||||||
else break;
|
else break;
|
||||||
scoreidx++;
|
scoreidx++;
|
||||||
@ -1210,7 +1210,7 @@ void zaddGenericCommand(redisClient *c, int flags) {
|
|||||||
int incr = (flags & ZADD_INCR) != 0;
|
int incr = (flags & ZADD_INCR) != 0;
|
||||||
int nx = (flags & ZADD_NX) != 0;
|
int nx = (flags & ZADD_NX) != 0;
|
||||||
int xx = (flags & ZADD_XX) != 0;
|
int xx = (flags & ZADD_XX) != 0;
|
||||||
int retch = (flags & ZADD_RETCH) != 0;
|
int ch = (flags & ZADD_CH) != 0;
|
||||||
|
|
||||||
/* After the options, we expect to have an even number of args, since
|
/* After the options, we expect to have an even number of args, since
|
||||||
* we expect any number of score-element pairs. */
|
* we expect any number of score-element pairs. */
|
||||||
@ -1356,7 +1356,7 @@ reply_to_client:
|
|||||||
else
|
else
|
||||||
addReply(c,shared.nullbulk);
|
addReply(c,shared.nullbulk);
|
||||||
} else { /* ZADD. */
|
} else { /* ZADD. */
|
||||||
addReplyLongLong(c,retch ? added+updated : added);
|
addReplyLongLong(c,ch ? added+updated : added);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user