mirror of
http://github.com/valkey-io/valkey
synced 2024-11-23 03:33:28 +00:00
ZINCRSCOREBY => ZINCRBY
This commit is contained in:
parent
e2665397a7
commit
7db723adb2
1
TODO
1
TODO
@ -2,7 +2,6 @@ VERSION 1.1 TODO
|
|||||||
|
|
||||||
* For now only the last argument gets integer encoded, so make sure that: 1) every multi bulk commands implemented will have the last arg that is indeed a value, and not used otherwise. 2) to explicitly call the function to encode the object in MSET and other commands where there are multiple "values".
|
* For now only the last argument gets integer encoded, so make sure that: 1) every multi bulk commands implemented will have the last arg that is indeed a value, and not used otherwise. 2) to explicitly call the function to encode the object in MSET and other commands where there are multiple "values".
|
||||||
* Man pages for MSET MSETNX and SRANDMEMBER, Z-commands, ...
|
* Man pages for MSET MSETNX and SRANDMEMBER, Z-commands, ...
|
||||||
* ZSETs missing stuff: ZINCRBY
|
|
||||||
* Use strcoll() to compare objects in sorted sets, like it already happens for SORT.
|
* Use strcoll() to compare objects in sorted sets, like it already happens for SORT.
|
||||||
* LPOPPUSH, EXPIRE, EXPIREAT, ZSCORE, SRANDMEMBER tests.
|
* LPOPPUSH, EXPIRE, EXPIREAT, ZSCORE, SRANDMEMBER tests.
|
||||||
* Write docs for the "STORE" operaiton of SORT, and GET "#" option.
|
* Write docs for the "STORE" operaiton of SORT, and GET "#" option.
|
||||||
|
@ -93,7 +93,7 @@ static struct redisCommand cmdTable[] = {
|
|||||||
{"sdiffstore",-3,REDIS_CMD_INLINE},
|
{"sdiffstore",-3,REDIS_CMD_INLINE},
|
||||||
{"smembers",2,REDIS_CMD_INLINE},
|
{"smembers",2,REDIS_CMD_INLINE},
|
||||||
{"zadd",4,REDIS_CMD_BULK},
|
{"zadd",4,REDIS_CMD_BULK},
|
||||||
{"zincrscoreby",4,REDIS_CMD_BULK},
|
{"zincrby",4,REDIS_CMD_BULK},
|
||||||
{"zrem",3,REDIS_CMD_BULK},
|
{"zrem",3,REDIS_CMD_BULK},
|
||||||
{"zremrangebyscore",4,REDIS_CMD_INLINE},
|
{"zremrangebyscore",4,REDIS_CMD_INLINE},
|
||||||
{"zrange",4,REDIS_CMD_INLINE},
|
{"zrange",4,REDIS_CMD_INLINE},
|
||||||
|
14
redis.c
14
redis.c
@ -466,7 +466,7 @@ static void debugCommand(redisClient *c);
|
|||||||
static void msetCommand(redisClient *c);
|
static void msetCommand(redisClient *c);
|
||||||
static void msetnxCommand(redisClient *c);
|
static void msetnxCommand(redisClient *c);
|
||||||
static void zaddCommand(redisClient *c);
|
static void zaddCommand(redisClient *c);
|
||||||
static void zincrscorebyCommand(redisClient *c);
|
static void zincrbyCommand(redisClient *c);
|
||||||
static void zrangeCommand(redisClient *c);
|
static void zrangeCommand(redisClient *c);
|
||||||
static void zrangebyscoreCommand(redisClient *c);
|
static void zrangebyscoreCommand(redisClient *c);
|
||||||
static void zrevrangeCommand(redisClient *c);
|
static void zrevrangeCommand(redisClient *c);
|
||||||
@ -514,7 +514,7 @@ static struct redisCommand cmdTable[] = {
|
|||||||
{"sdiffstore",sdiffstoreCommand,-3,REDIS_CMD_INLINE|REDIS_CMD_DENYOOM},
|
{"sdiffstore",sdiffstoreCommand,-3,REDIS_CMD_INLINE|REDIS_CMD_DENYOOM},
|
||||||
{"smembers",sinterCommand,2,REDIS_CMD_INLINE},
|
{"smembers",sinterCommand,2,REDIS_CMD_INLINE},
|
||||||
{"zadd",zaddCommand,4,REDIS_CMD_BULK|REDIS_CMD_DENYOOM},
|
{"zadd",zaddCommand,4,REDIS_CMD_BULK|REDIS_CMD_DENYOOM},
|
||||||
{"zincrscoreby",zincrscorebyCommand,4,REDIS_CMD_BULK|REDIS_CMD_DENYOOM},
|
{"zincrby",zincrbyCommand,4,REDIS_CMD_BULK|REDIS_CMD_DENYOOM},
|
||||||
{"zrem",zremCommand,3,REDIS_CMD_BULK},
|
{"zrem",zremCommand,3,REDIS_CMD_BULK},
|
||||||
{"zremrangebyscore",zremrangebyscoreCommand,4,REDIS_CMD_INLINE},
|
{"zremrangebyscore",zremrangebyscoreCommand,4,REDIS_CMD_INLINE},
|
||||||
{"zrange",zrangeCommand,4,REDIS_CMD_INLINE},
|
{"zrange",zrangeCommand,4,REDIS_CMD_INLINE},
|
||||||
@ -4229,9 +4229,9 @@ static zskiplistNode *zslFirstWithScore(zskiplist *zsl, double score) {
|
|||||||
|
|
||||||
/* The actual Z-commands implementations */
|
/* The actual Z-commands implementations */
|
||||||
|
|
||||||
/* This generic command implements both ZADD and ZINCRSCOREBY.
|
/* This generic command implements both ZADD and ZINCRBY.
|
||||||
* scoreval is the score if the operation is a ZADD (doincrement == 0) or
|
* scoreval is the score if the operation is a ZADD (doincrement == 0) or
|
||||||
* the increment if the operation is a ZINCRSCOREBY (doincrement == 1). */
|
* the increment if the operation is a ZINCRBY (doincrement == 1). */
|
||||||
static void zaddGenericCommand(redisClient *c, robj *key, robj *ele, double scoreval, int doincrement) {
|
static void zaddGenericCommand(redisClient *c, robj *key, robj *ele, double scoreval, int doincrement) {
|
||||||
robj *zsetobj;
|
robj *zsetobj;
|
||||||
zset *zs;
|
zset *zs;
|
||||||
@ -4250,7 +4250,7 @@ static void zaddGenericCommand(redisClient *c, robj *key, robj *ele, double scor
|
|||||||
}
|
}
|
||||||
zs = zsetobj->ptr;
|
zs = zsetobj->ptr;
|
||||||
|
|
||||||
/* Ok now since we implement both ZADD and ZINCRSCOREBY here the code
|
/* Ok now since we implement both ZADD and ZINCRBY here the code
|
||||||
* needs to handle the two different conditions. It's all about setting
|
* needs to handle the two different conditions. It's all about setting
|
||||||
* '*score', that is, the new score to set, to the right value. */
|
* '*score', that is, the new score to set, to the right value. */
|
||||||
score = zmalloc(sizeof(double));
|
score = zmalloc(sizeof(double));
|
||||||
@ -4270,7 +4270,7 @@ static void zaddGenericCommand(redisClient *c, robj *key, robj *ele, double scor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* What follows is a simple remove and re-insert operation that is common
|
/* What follows is a simple remove and re-insert operation that is common
|
||||||
* to both ZADD and ZINCRSCOREBY... */
|
* to both ZADD and ZINCRBY... */
|
||||||
if (dictAdd(zs->dict,ele,score) == DICT_OK) {
|
if (dictAdd(zs->dict,ele,score) == DICT_OK) {
|
||||||
/* case 1: New element */
|
/* case 1: New element */
|
||||||
incrRefCount(ele); /* added to hash */
|
incrRefCount(ele); /* added to hash */
|
||||||
@ -4317,7 +4317,7 @@ static void zaddCommand(redisClient *c) {
|
|||||||
zaddGenericCommand(c,c->argv[1],c->argv[3],scoreval,0);
|
zaddGenericCommand(c,c->argv[1],c->argv[3],scoreval,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zincrscorebyCommand(redisClient *c) {
|
static void zincrbyCommand(redisClient *c) {
|
||||||
double scoreval;
|
double scoreval;
|
||||||
|
|
||||||
scoreval = strtod(c->argv[2]->ptr,NULL);
|
scoreval = strtod(c->argv[2]->ptr,NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user