mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 00:52:38 +00:00
GETSET implemented
This commit is contained in:
parent
b8b553c84f
commit
a431eb74ba
@ -85,6 +85,7 @@ static struct redisCommand cmdTable[] = {
|
||||
{"smembers",2,REDIS_CMD_INLINE},
|
||||
{"incrby",3,REDIS_CMD_INLINE},
|
||||
{"decrby",3,REDIS_CMD_INLINE},
|
||||
{"getset",3,REDIS_CMD_BULK},
|
||||
{"randomkey",1,REDIS_CMD_INLINE},
|
||||
{"select",2,REDIS_CMD_INLINE},
|
||||
{"move",3,REDIS_CMD_INLINE},
|
||||
|
14
redis.c
14
redis.c
@ -356,6 +356,7 @@ static void infoCommand(redisClient *c);
|
||||
static void mgetCommand(redisClient *c);
|
||||
static void monitorCommand(redisClient *c);
|
||||
static void expireCommand(redisClient *c);
|
||||
static void getSetCommand(redisClient *c);
|
||||
|
||||
/*================================= Globals ================================= */
|
||||
|
||||
@ -391,6 +392,7 @@ static struct redisCommand cmdTable[] = {
|
||||
{"smembers",sinterCommand,2,REDIS_CMD_INLINE},
|
||||
{"incrby",incrbyCommand,3,REDIS_CMD_INLINE},
|
||||
{"decrby",decrbyCommand,3,REDIS_CMD_INLINE},
|
||||
{"getset",getSetCommand,3,REDIS_CMD_BULK},
|
||||
{"randomkey",randomkeyCommand,1,REDIS_CMD_INLINE},
|
||||
{"select",selectCommand,2,REDIS_CMD_INLINE},
|
||||
{"move",moveCommand,3,REDIS_CMD_INLINE},
|
||||
@ -2174,6 +2176,18 @@ static void getCommand(redisClient *c) {
|
||||
}
|
||||
}
|
||||
|
||||
static void getSetCommand(redisClient *c) {
|
||||
getCommand(c);
|
||||
if (dictAdd(c->db->dict,c->argv[1],c->argv[2]) == DICT_ERR) {
|
||||
dictReplace(c->db->dict,c->argv[1],c->argv[2]);
|
||||
} else {
|
||||
incrRefCount(c->argv[1]);
|
||||
}
|
||||
incrRefCount(c->argv[2]);
|
||||
server.dirty++;
|
||||
removeExpire(c->db,c->argv[1]);
|
||||
}
|
||||
|
||||
static void mgetCommand(redisClient *c) {
|
||||
int j;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user