From 2ed22c8b29039dce0ae795c4ba3c334b9ec860f4 Mon Sep 17 00:00:00 2001 From: antirez Date: Sat, 17 Oct 2009 22:02:59 +0200 Subject: [PATCH] MSET fixed, was not able to replace keys already set for a stupid bug --- redis.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/redis.c b/redis.c index 3077badb..c8cb67f0 100644 --- a/redis.c +++ b/redis.c @@ -4128,9 +4128,16 @@ static void msetGenericCommand(redisClient *c, int nx) { } for (j = 1; j < c->argc; j += 2) { - dictAdd(c->db->dict,c->argv[j],c->argv[j+1]); - incrRefCount(c->argv[j]); - incrRefCount(c->argv[j+1]); + int retval; + + retval = dictAdd(c->db->dict,c->argv[j],c->argv[j+1]); + if (retval == DICT_ERR) { + dictReplace(c->db->dict,c->argv[j],c->argv[j+1]); + incrRefCount(c->argv[j+1]); + } else { + incrRefCount(c->argv[j]); + incrRefCount(c->argv[j+1]); + } removeExpire(c->db,c->argv[j]); } server.dirty += (c->argc-1)/2; -- 2.45.2