From 43e5ccdf57e2144a8a43c04c5a64e91a155a78fb Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Fri, 30 Oct 2009 00:21:04 +0100
Subject: [PATCH] EXPIRE behaviour changed a bit, a negative TTL or an EXPIREAT
 with unix time in the past will now delete the key. It seems saner to me than
 doing nothing.

---
 redis.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/redis.c b/redis.c
index 86a06af1..0040483a 100644
--- a/redis.c
+++ b/redis.c
@@ -4746,8 +4746,9 @@ static void expireGenericCommand(redisClient *c, robj *key, time_t seconds) {
         addReply(c,shared.czero);
         return;
     }
-    if (seconds <= 0) {
-        addReply(c, shared.czero);
+    if (seconds < 0) {
+        if (deleteKey(c->db,key)) server.dirty++;
+        addReply(c, shared.cone);
         return;
     } else {
         time_t when = time(NULL)+seconds;