MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / touchWatchedKey

Function touchWatchedKey

src/multi.cpp:378–396  ·  view source on GitHub ↗

"Touch" a key, so that if this key is being WATCHed by some client the * next EXEC will fail. */

Source from the content-addressed store, hash-verified

376/* "Touch" a key, so that if this key is being WATCHed by some client the
377 * next EXEC will fail. */
378void touchWatchedKey(redisDb *db, robj *key) {
379 serverAssert(GlobalLocksAcquired());
380 list *clients;
381 listIter li;
382 listNode *ln;
383
384 if (dictSize(db->watched_keys) == 0) return;
385 clients = (list*)dictFetchValue(db->watched_keys, key);
386 if (!clients) return;
387
388 /* Mark all the clients watching this key as CLIENT_DIRTY_CAS */
389 /* Check if we are already watching for this key */
390 listRewind(clients,&li);
391 while((ln = listNext(&li))) {
392 client *c = (client*)listNodeValue(ln);
393
394 c->flags |= CLIENT_DIRTY_CAS;
395 }
396}
397
398/* Set CLIENT_DIRTY_CAS to all clients of DB when DB is dirty.
399 * It may happen in the following situations:

Callers 1

signalModifiedKeyFunction · 0.85

Calls 4

GlobalLocksAcquiredFunction · 0.85
dictFetchValueFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85

Tested by

no test coverage detected