MCPcopy Create free account
hub / github.com/F-Stack/f-stack / touchAllWatchedKeysInDb

Function touchAllWatchedKeysInDb

app/redis-6.2.6/src/multi.c:398–421  ·  view source on GitHub ↗

Set CLIENT_DIRTY_CAS to all clients of DB when DB is dirty. * It may happen in the following situations: * FLUSHDB, FLUSHALL, SWAPDB * * replaced_with: for SWAPDB, the WATCH should be invalidated if * the key exists in either of them, and skipped only if it * doesn't exist in both. */

Source from the content-addressed store, hash-verified

396 * the key exists in either of them, and skipped only if it
397 * doesn't exist in both. */
398void touchAllWatchedKeysInDb(redisDb *emptied, redisDb *replaced_with) {
399 listIter li;
400 listNode *ln;
401 dictEntry *de;
402
403 if (dictSize(emptied->watched_keys) == 0) return;
404
405 dictIterator *di = dictGetSafeIterator(emptied->watched_keys);
406 while((de = dictNext(di)) != NULL) {
407 robj *key = dictGetKey(de);
408 list *clients = dictGetVal(de);
409 if (!clients) continue;
410 listRewind(clients,&li);
411 while((ln = listNext(&li))) {
412 client *c = listNodeValue(ln);
413 if (dictFind(emptied->dict, key->ptr)) {
414 c->flags |= CLIENT_DIRTY_CAS;
415 } else if (replaced_with && dictFind(replaced_with->dict, key->ptr)) {
416 c->flags |= CLIENT_DIRTY_CAS;
417 }
418 }
419 }
420 dictReleaseIterator(di);
421}
422
423void watchCommand(client *c) {
424 int j;

Callers 2

signalFlushedDbFunction · 0.85
dbSwapDatabasesFunction · 0.85

Calls 6

dictGetSafeIteratorFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
dictNextFunction · 0.70
dictFindFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected