X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/cea8c5cd75b88cd5a13d9b253d792cc045d28b62..bb831c313c32a64446484e66c275aaba55d2d818:/src/t_hash.c?ds=sidebyside diff --git a/src/t_hash.c b/src/t_hash.c index 5e7525bd..83ca5b27 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -396,17 +396,25 @@ void hmgetCommand(redisClient *c) { void hdelCommand(redisClient *c) { robj *o; + int j, deleted = 0; + if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL || checkType(c,o,REDIS_HASH)) return; - if (hashTypeDelete(o,c->argv[2])) { - if (hashTypeLength(o) == 0) dbDelete(c->db,c->argv[1]); - addReply(c,shared.cone); + for (j = 2; j < c->argc; j++) { + if (hashTypeDelete(o,c->argv[j])) { + deleted++; + if (hashTypeLength(o) == 0) { + dbDelete(c->db,c->argv[1]); + break; + } + } + } + if (deleted) { signalModifiedKey(c->db,c->argv[1]); - server.dirty++; - } else { - addReply(c,shared.czero); + server.dirty += deleted; } + addReplyLongLong(c,deleted); } void hlenCommand(redisClient *c) {