]> git.saurik.com Git - redis.git/blobdiff - src/sort.c
SORT with STORE removes key if result is empty. This fixes issue #227.
[redis.git] / src / sort.c
index 7e50582efcd76602c2f9f9c5b2889ef424728a0e..038aec27afbbb3b9f233cf8c0967734a6d71a1c2 100644 (file)
@@ -367,9 +367,14 @@ void sortCommand(redisClient *c) {
                 }
             }
         }
-        if (outputlen) setKey(c->db,storekey,sobj);
+        if (outputlen) {
+            setKey(c->db,storekey,sobj);
+            server.dirty += outputlen;
+        } else if (dbDelete(c->db,storekey)) {
+            signalModifiedKey(c->db,storekey);
+            server.dirty++;
+        }
         decrRefCount(sobj);
-        server.dirty += outputlen;
         addReplyLongLong(c,outputlen);
     }