summaryrefslogtreecommitdiff
path: root/src/multi.c
diff options
context:
space:
mode:
authorzhaozhao.zz <276441700@qq.com>2021-07-06 15:01:37 +0800
committerGitHub <noreply@github.com>2021-07-06 15:01:37 +0800
commit5ea3c3db15ad2b67ae3c027ba8f10f3ea19d18f9 (patch)
tree361df43767e5dcf62713e0a7f8745e71f63b6136 /src/multi.c
parentf06d782f5abcb30efb0117841232828ed3e129bf (diff)
downloadredis-5ea3c3db15ad2b67ae3c027ba8f10f3ea19d18f9.tar.gz
a little optimization in touchAllWatchedKeysInDb (#9200)
touch keys only if the key is in one of the dbs, in case rewind the list when the key doesn't exist.
Diffstat (limited to 'src/multi.c')
-rw-r--r--src/multi.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/multi.c b/src/multi.c
index eab620d6d..d3b73c78b 100644
--- a/src/multi.c
+++ b/src/multi.c
@@ -380,14 +380,14 @@ void touchAllWatchedKeysInDb(redisDb *emptied, redisDb *replaced_with) {
dictIterator *di = dictGetSafeIterator(emptied->watched_keys);
while((de = dictNext(di)) != NULL) {
robj *key = dictGetKey(de);
- list *clients = dictGetVal(de);
- if (!clients) continue;
- listRewind(clients,&li);
- while((ln = listNext(&li))) {
- client *c = listNodeValue(ln);
- if (dictFind(emptied->dict, key->ptr)) {
- c->flags |= CLIENT_DIRTY_CAS;
- } else if (replaced_with && dictFind(replaced_with->dict, key->ptr)) {
+ if (dictFind(emptied->dict, key->ptr) ||
+ (replaced_with && dictFind(replaced_with->dict, key->ptr)))
+ {
+ list *clients = dictGetVal(de);
+ if (!clients) continue;
+ listRewind(clients,&li);
+ while((ln = listNext(&li))) {
+ client *c = listNodeValue(ln);
c->flags |= CLIENT_DIRTY_CAS;
}
}