summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-06-13 10:35:51 +0200
committerantirez <antirez@gmail.com>2017-06-27 18:05:37 +0200
commite3641c8deee1bad3ec55783e2db0ddce4283254e (patch)
tree0e95edf246b5a7bd4b89af881ee9e49393f2c4a6
parent9ce105add50662b66ea4fd42dfdc22c0fb52d6d6 (diff)
downloadredis-e3641c8deee1bad3ec55783e2db0ddce4283254e.tar.gz
Fix PERSIST expired key resuscitation issue #4048.
-rw-r--r--src/db.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/db.c b/src/db.c
index 75905e2de..6222fb094 100644
--- a/src/db.c
+++ b/src/db.c
@@ -90,7 +90,7 @@ robj *lookupKeyReadWithFlags(redisDb *db, robj *key, int flags) {
if (expireIfNeeded(db,key) == 1) {
/* Key expired. If we are in the context of a master, expireIfNeeded()
- * returns 0 only when the key does not exist at all, so it's save
+ * returns 0 only when the key does not exist at all, so it's safe
* to return NULL ASAP. */
if (server.masterhost == NULL) return NULL;
@@ -1033,18 +1033,15 @@ void pttlCommand(client *c) {
}
void persistCommand(client *c) {
- dictEntry *de;
-
- de = dictFind(c->db->dict,c->argv[1]->ptr);
- if (de == NULL) {
- addReply(c,shared.czero);
- } else {
+ if (lookupKeyWrite(c->db,c->argv[1])) {
if (removeExpire(c->db,c->argv[1])) {
addReply(c,shared.cone);
server.dirty++;
} else {
addReply(c,shared.czero);
}
+ } else {
+ addReply(c,shared.czero);
}
}