diff options
author | zhaozhao.zz <276441700@qq.com> | 2021-07-06 15:01:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-06 15:01:37 +0800 |
commit | 5ea3c3db15ad2b67ae3c027ba8f10f3ea19d18f9 (patch) | |
tree | 361df43767e5dcf62713e0a7f8745e71f63b6136 /src | |
parent | f06d782f5abcb30efb0117841232828ed3e129bf (diff) | |
download | redis-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')
-rw-r--r-- | src/multi.c | 16 |
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; } } |