]> git.saurik.com Git - redis.git/commitdiff
WATCH will now consider touched keys target of EXPIRE command after the WATCH is...
authorantirez <antirez@gmail.com>
Mon, 5 Jul 2010 17:38:12 +0000 (19:38 +0200)
committerantirez <antirez@gmail.com>
Mon, 5 Jul 2010 17:38:12 +0000 (19:38 +0200)
src/db.c
tests/unit/cas.tcl

index e1e82cb22fcd30540f97e2846b7bb020d6eb3531..d5e0d1e8425f65855d3c74c675da671bcede9f24 100644 (file)
--- a/src/db.c
+++ b/src/db.c
@@ -472,11 +472,13 @@ void expireGenericCommand(redisClient *c, robj *key, robj *param, long offset) {
     if (seconds <= 0) {
         if (dbDelete(c->db,key)) server.dirty++;
         addReply(c, shared.cone);
+        touchWatchedKey(c->db,key);
         return;
     } else {
         time_t when = time(NULL)+seconds;
         if (setExpire(c->db,key,when)) {
             addReply(c,shared.cone);
+            touchWatchedKey(c->db,key);
             server.dirty++;
         } else {
             addReply(c,shared.czero);
index dc6a5ef7c38cbae2d5cf9da6dec1f32ed817a7da..d420d9e29fbe8a9cf73f092fe43c4f0bb456bfae 100644 (file)
@@ -111,4 +111,25 @@ start_server {tags {"cas"}} {
         r ping
         r exec
     } {PONG}
+
+    test {WATCH will consider touched keys target of EXPIRE} {
+        r del x
+        r set x foo
+        r watch x
+        r expire x 10
+        r multi
+        r ping
+        r exec
+    } {}
+
+    test {WATCH will not consider touched expired keys} {
+        r del x
+        r set x foo
+        r expire x 2
+        r watch x
+        after 3000
+        r multi
+        r ping
+        r exec
+    } {PONG}
 }