Unverified Commit 5ea3c3db authored by zhaozhao.zz's avatar zhaozhao.zz Committed by GitHub
Browse files

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.
parent f06d782f
...@@ -380,14 +380,14 @@ void touchAllWatchedKeysInDb(redisDb *emptied, redisDb *replaced_with) { ...@@ -380,14 +380,14 @@ void touchAllWatchedKeysInDb(redisDb *emptied, redisDb *replaced_with) {
dictIterator *di = dictGetSafeIterator(emptied->watched_keys); dictIterator *di = dictGetSafeIterator(emptied->watched_keys);
while((de = dictNext(di)) != NULL) { while((de = dictNext(di)) != NULL) {
robj *key = dictGetKey(de); robj *key = dictGetKey(de);
list *clients = dictGetVal(de); if (dictFind(emptied->dict, key->ptr) ||
if (!clients) continue; (replaced_with && dictFind(replaced_with->dict, key->ptr)))
listRewind(clients,&li); {
while((ln = listNext(&li))) { list *clients = dictGetVal(de);
client *c = listNodeValue(ln); if (!clients) continue;
if (dictFind(emptied->dict, key->ptr)) { listRewind(clients,&li);
c->flags |= CLIENT_DIRTY_CAS; while((ln = listNext(&li))) {
} else if (replaced_with && dictFind(replaced_with->dict, key->ptr)) { client *c = listNodeValue(ln);
c->flags |= CLIENT_DIRTY_CAS; c->flags |= CLIENT_DIRTY_CAS;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment