]> git.saurik.com Git - redis.git/blobdiff - src/t_hash.c
Issue #131. stime/utime reported in INFO was inverted. Fixed thanks to Didier Spezia.
[redis.git] / src / t_hash.c
index 488bf6b7a039449137ca874dbfba50687ba256fa..3ccdfd142c81ac9a4328fe1f8fcbfaaf042458ee 100644 (file)
@@ -160,7 +160,7 @@ hashTypeIterator *hashTypeInitIterator(robj *subject) {
     } else if (hi->encoding == REDIS_ENCODING_HT) {
         hi->di = dictGetIterator(subject->ptr);
     } else {
-        redisAssert(NULL);
+        redisAssertWithInfo(NULL,subject,0);
     }
     return hi;
 }
@@ -250,7 +250,7 @@ void convertToRealHash(robj *o) {
     unsigned int klen, vlen;
     dict *dict = dictCreate(&hashDictType,NULL);
 
-    redisAssert(o->type == REDIS_HASH && o->encoding != REDIS_ENCODING_HT);
+    redisAssertWithInfo(NULL,o,o->type == REDIS_HASH && o->encoding != REDIS_ENCODING_HT);
     p = zipmapRewind(zm);
     while((p = zipmapNext(p,&key,&klen,&val,&vlen)) != NULL) {
         robj *keyobj, *valobj;
@@ -279,7 +279,7 @@ void hsetCommand(redisClient *c) {
     hashTypeTryObjectEncoding(o,&c->argv[2], &c->argv[3]);
     update = hashTypeSet(o,c->argv[2],c->argv[3]);
     addReply(c, update ? shared.czero : shared.cone);
-    touchWatchedKey(c->db,c->argv[1]);
+    signalModifiedKey(c->db,c->argv[1]);
     server.dirty++;
 }
 
@@ -294,7 +294,7 @@ void hsetnxCommand(redisClient *c) {
         hashTypeTryObjectEncoding(o,&c->argv[2], &c->argv[3]);
         hashTypeSet(o,c->argv[2],c->argv[3]);
         addReply(c, shared.cone);
-        touchWatchedKey(c->db,c->argv[1]);
+        signalModifiedKey(c->db,c->argv[1]);
         server.dirty++;
     }
 }
@@ -315,7 +315,7 @@ void hmsetCommand(redisClient *c) {
         hashTypeSet(o,c->argv[i],c->argv[i+1]);
     }
     addReply(c, shared.ok);
-    touchWatchedKey(c->db,c->argv[1]);
+    signalModifiedKey(c->db,c->argv[1]);
     server.dirty++;
 }
 
@@ -342,7 +342,7 @@ void hincrbyCommand(redisClient *c) {
     hashTypeSet(o,c->argv[2],new);
     decrRefCount(new);
     addReplyLongLong(c,value);
-    touchWatchedKey(c->db,c->argv[1]);
+    signalModifiedKey(c->db,c->argv[1]);
     server.dirty++;
 }
 
@@ -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);
-        touchWatchedKey(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])) {
+            deleted++;
+            if (hashTypeLength(o) == 0) {
+                dbDelete(c->db,c->argv[1]);
+                break;
+            }
+        }
+    }
+    if (deleted) {
+        signalModifiedKey(c->db,c->argv[1]);
+        server.dirty += deleted;
     }
+    addReplyLongLong(c,deleted);
 }
 
 void hlenCommand(redisClient *c) {