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

Function trackingRememberKeyToBroadcast

src/tracking.cpp:320–336  ·  view source on GitHub ↗

This function is called when a key is modified in Redis and in the case * we have at least one client with the BCAST mode enabled. * Its goal is to set the key in the right broadcast state if the key * matches one or more prefixes in the prefix table. Later when we * return to the event loop, we'll send invalidation messages to the * clients subscribed to each prefix. */

Source from the content-addressed store, hash-verified

318 * return to the event loop, we'll send invalidation messages to the
319 * clients subscribed to each prefix. */
320void trackingRememberKeyToBroadcast(client *c, char *keyname, size_t keylen) {
321 raxIterator ri;
322 raxStart(&ri,PrefixTable);
323 raxSeek(&ri,"^",NULL,0);
324 while(raxNext(&ri)) {
325 if (ri.key_len > keylen) continue;
326 if (ri.key_len != 0 && memcmp(ri.key,keyname,ri.key_len) != 0)
327 continue;
328 bcastState *bs = (bcastState*)ri.data;
329 /* We insert the client pointer as associated value in the radix
330 * tree. This way we know who was the client that did the last
331 * change to the key, and can avoid sending the notification in the
332 * case the client is in NOLOOP mode. */
333 raxInsert(bs->keys,(unsigned char*)keyname,keylen,c,NULL);
334 }
335 raxStop(&ri);
336}
337
338/* This function is called from signalModifiedKey() or other places in Redis
339 * when a key changes value. In the context of keys tracking, our task here is

Callers 1

trackingInvalidateKeyRawFunction · 0.85

Calls 5

raxStartFunction · 0.85
raxSeekFunction · 0.85
raxNextFunction · 0.85
raxInsertFunction · 0.85
raxStopFunction · 0.85

Tested by

no test coverage detected