a little optimization in touchAllWatchedKeysInDb
touch keys only if the key is in one of the dbs,
in case rewind the list when the key doesn't exist.
@@ -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);
+ 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);
- if (dictFind(emptied->dict, key->ptr)) {
- c->flags |= CLIENT_DIRTY_CAS;
- } else if (replaced_with && dictFind(replaced_with->dict, key->ptr)) {
c->flags |= CLIENT_DIRTY_CAS;
}
}
