summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-03-28 12:45:07 +0100
committerantirez <antirez@gmail.com>2013-03-28 12:45:07 +0100
commit140260409eef36dd4d155e488eb9531cf119728e (patch)
treea97311b3e526512c075449e23332e365b28d94ed
parent601cea665d63bb7b5e335ce922dc4c01905e04e7 (diff)
downloadredis-140260409eef36dd4d155e488eb9531cf119728e.tar.gz
EXPIRE should not resurrect keys. Issue #1026.
-rw-r--r--src/db.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/db.c b/src/db.c
index bfa607671..64be530ee 100644
--- a/src/db.c
+++ b/src/db.c
@@ -562,7 +562,6 @@ int expireIfNeeded(redisDb *db, robj *key) {
* unit is either UNIT_SECONDS or UNIT_MILLISECONDS, and is only used for
* the argv[2] parameter. The basetime is always specified in milliseconds. */
void expireGenericCommand(redisClient *c, long long basetime, int unit) {
- dictEntry *de;
robj *key = c->argv[1], *param = c->argv[2];
long long when; /* unix time in milliseconds when the key will expire. */
@@ -572,11 +571,12 @@ void expireGenericCommand(redisClient *c, long long basetime, int unit) {
if (unit == UNIT_SECONDS) when *= 1000;
when += basetime;
- de = dictFind(c->db->dict,key->ptr);
- if (de == NULL) {
+ /* No key, return zero. */
+ if (lookupKeyRead(c->db,key) == NULL) {
addReply(c,shared.czero);
return;
}
+
/* EXPIRE with negative TTL, or EXPIREAT with a timestamp into the past
* should never be executed as a DEL when load the AOF or in the context
* of a slave instance.