]> git.saurik.com Git - redis.git/commitdiff
PERSIST: a fix and some basic test
authorantirez <antirez@gmail.com>
Tue, 3 Aug 2010 12:25:22 +0000 (14:25 +0200)
committerantirez <antirez@gmail.com>
Tue, 3 Aug 2010 12:25:22 +0000 (14:25 +0200)
src/db.c
tests/unit/expire.tcl

index 81e41430dcd3a399741cc5da6445ad8c933c54e3..0dec95b1c5763a8ecea00b2a469cebf14ce5ffb4 100644 (file)
--- a/src/db.c
+++ b/src/db.c
@@ -532,9 +532,11 @@ void persistCommand(redisClient *c) {
     if (de == NULL) {
         addReply(c,shared.czero);
     } else {
-        if (removeExpire(c->db,c->argv[1]))
+        if (removeExpire(c->db,c->argv[1])) {
             addReply(c,shared.cone);
-        else
+            server.dirty++;
+        } else {
             addReply(c,shared.czero);
+        }
     }
 }
index 5de907abb1223af8a21b01a3a0aa6d3c2e702748..6f16ed58956a1d0605e84a7061e294969aac360f 100644 (file)
@@ -60,4 +60,15 @@ start_server {tags {"expire"}} {
         catch {r setex z -10 foo} e
         set _ $e
     } {*invalid expire*}
+
+    test {PERSIST can undo an EXPIRE} {
+        r set x foo
+        r expire x 50
+        list [r ttl x] [r persist x] [r ttl x] [r get x]
+    } {50 1 -1 foo}
+
+    test {PERSIST returns 0 against non existing or non volatile keys} {
+        r set x foo
+        list [r persist foo] [r persist nokeyatall]
+    } {0 0}
 }