mirror of
https://github.com/fluencelabs/redis
synced 2025-03-17 16:10:50 +00:00
WATCH will now consider touched keys target of EXPIRE command after the WATCH is performed, but not before
This commit is contained in:
parent
3688d7f308
commit
b7a8daef60
2
src/db.c
2
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);
|
||||
|
@ -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}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user