X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/4365e5b2d32798c168a8376fad891c0e5cccb4ec..aa2bf6ba8bec776c02d8055ac856d96926137895:/src/db.c?ds=sidebyside diff --git a/src/db.c b/src/db.c index 9fe9a003..a73d1fbf 100644 --- a/src/db.c +++ b/src/db.c @@ -614,6 +614,13 @@ void ttlGenericCommand(redisClient *c, int output_ms) { long long expire, ttl = -1; expire = getExpire(c->db,c->argv[1]); + /* If the key does not exist at all, return -2 */ + if (expire == -1 && lookupKeyRead(c->db,c->argv[1]) == NULL) { + addReplyLongLong(c,-2); + return; + } + /* The key exists. Return -1 if it has no expire, or the actual + * TTL value otherwise. */ if (expire != -1) { ttl = expire-mstime(); if (ttl < 0) ttl = -1;