summaryrefslogtreecommitdiff
path: root/src/t_hash.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2011-04-19 17:07:55 +0200
committerantirez <antirez@gmail.com>2011-04-19 17:07:55 +0200
commit64a13a36e685c318319a70b775f91f2c34bcc34f (patch)
tree41e5e1608d2abfea16e9f918c5bd1673cb389350 /src/t_hash.c
parent271f08784264e25c3dbcd751f8c9ee1b1ad8306e (diff)
downloadredis-64a13a36e685c318319a70b775f91f2c34bcc34f.tar.gz
variadic HDEL with tests
Diffstat (limited to 'src/t_hash.c')
-rw-r--r--src/t_hash.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/t_hash.c b/src/t_hash.c
index 5e7525bd1..4b9b37d69 100644
--- a/src/t_hash.c
+++ b/src/t_hash.c
@@ -396,17 +396,22 @@ 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])) {
+ if (hashTypeLength(o) == 0) dbDelete(c->db,c->argv[1]);
+ deleted++;
+ }
+ }
+ 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) {