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

Function unwatchAllKeys

src/multi.cpp:334–358  ·  view source on GitHub ↗

Unwatch all the keys watched by this client. To clean the EXEC dirty * flag is up to the caller. */

Source from the content-addressed store, hash-verified

332/* Unwatch all the keys watched by this client. To clean the EXEC dirty
333 * flag is up to the caller. */
334void unwatchAllKeys(client *c) {
335 listIter li;
336 listNode *ln;
337
338 if (listLength(c->watched_keys) == 0) return;
339 listRewind(c->watched_keys,&li);
340 while((ln = listNext(&li))) {
341 list *clients;
342 watchedKey *wk;
343
344 /* Lookup the watched key -> clients list and remove the client
345 * from the list */
346 wk = (watchedKey*)listNodeValue(ln);
347 clients = (decltype(clients))dictFetchValue(wk->db->watched_keys, wk->key);
348 serverAssertWithInfo(c,NULL,clients != NULL);
349 listDelNode(clients,listSearchKey(clients,c));
350 /* Kill the entry at all if this was the only client */
351 if (listLength(clients) == 0)
352 dictDelete(wk->db->watched_keys, wk->key);
353 /* Remove this watched key from the client->watched list */
354 listDelNode(c->watched_keys,ln);
355 decrRefCount(wk->key);
356 zfree(wk);
357 }
358}
359
360/* iterates over the watched_keys list and
361 * look for an expired key . */

Callers 4

discardTransactionFunction · 0.85
execCommandFunction · 0.85
unwatchCommandFunction · 0.85
freeClientFunction · 0.85

Calls 8

listRewindFunction · 0.85
listNextFunction · 0.85
dictFetchValueFunction · 0.85
listDelNodeFunction · 0.85
listSearchKeyFunction · 0.85
decrRefCountFunction · 0.85
zfreeFunction · 0.85
dictDeleteFunction · 0.70

Tested by

no test coverage detected