WATCH will now consider touched keys target of EXPIRE command after the WATCH is performed, but not before

This commit is contained in:
antirez 2010-07-05 19:38:12 +02:00
parent 3688d7f308
commit b7a8daef60
2 changed files with 23 additions and 0 deletions

View File

@ -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);

View 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}
}