mirror of
https://github.com/fluencelabs/redis
synced 2025-06-18 19:51:22 +00:00
variadic HDEL with tests
This commit is contained in:
@ -138,7 +138,7 @@ struct redisCommand redisCommandTable[] = {
|
||||
{"hmset",hmsetCommand,-4,REDIS_CMD_DENYOOM,NULL,1,1,1,0,0},
|
||||
{"hmget",hmgetCommand,-3,0,NULL,1,1,1,0,0},
|
||||
{"hincrby",hincrbyCommand,4,REDIS_CMD_DENYOOM,NULL,1,1,1,0,0},
|
||||
{"hdel",hdelCommand,3,0,NULL,1,1,1,0,0},
|
||||
{"hdel",hdelCommand,-3,0,NULL,1,1,1,0,0},
|
||||
{"hlen",hlenCommand,2,0,NULL,1,1,1,0,0},
|
||||
{"hkeys",hkeysCommand,2,0,NULL,1,1,1,0,0},
|
||||
{"hvals",hvalsCommand,2,0,NULL,1,1,1,0,0},
|
||||
|
19
src/t_hash.c
19
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);
|
||||
signalModifiedKey(c->db,c->argv[1]);
|
||||
server.dirty++;
|
||||
} else {
|
||||
addReply(c,shared.czero);
|
||||
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 += deleted;
|
||||
}
|
||||
addReplyLongLong(c,deleted);
|
||||
}
|
||||
|
||||
void hlenCommand(redisClient *c) {
|
||||
|
Reference in New Issue
Block a user