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

Function trackingRememberKeyToBroadcast

app/redis-6.2.6/src/tracking.c:316–332  ·  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

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