Commit 1fb4e8de authored by antirez's avatar antirez
Browse files

PERSIST: a fix and some basic test

parent a539d29a
...@@ -532,9 +532,11 @@ void persistCommand(redisClient *c) { ...@@ -532,9 +532,11 @@ void persistCommand(redisClient *c) {
if (de == NULL) { if (de == NULL) {
addReply(c,shared.czero); addReply(c,shared.czero);
} else { } else {
if (removeExpire(c->db,c->argv[1])) if (removeExpire(c->db,c->argv[1])) {
addReply(c,shared.cone); addReply(c,shared.cone);
else server.dirty++;
} else {
addReply(c,shared.czero); addReply(c,shared.czero);
}
} }
} }
...@@ -60,4 +60,15 @@ start_server {tags {"expire"}} { ...@@ -60,4 +60,15 @@ start_server {tags {"expire"}} {
catch {r setex z -10 foo} e catch {r setex z -10 foo} e
set _ $e set _ $e
} {*invalid expire*} } {*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}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment