diff --git a/src/db.c b/src/db.c index 86dabac8..6d39bb9b 100644 --- a/src/db.c +++ b/src/db.c @@ -93,7 +93,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; diff --git a/src/expire.c b/src/expire.c index 22b1f1da..d3a0e3f6 100644 --- a/src/expire.c +++ b/src/expire.c @@ -477,18 +477,15 @@ void pttlCommand(client *c) { /* PERSIST key */ 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); } }