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

Function trackingInvalidateKeyRaw

app/redis-6.2.6/src/tracking.c:350–395  ·  view source on GitHub ↗

This function is called from signalModifiedKey() or other places in Redis * when a key changes value. In the context of keys tracking, our task here is * to send a notification to every client that may have keys about such caching * slot. * * Note that 'c' may be NULL in case the operation was performed outside the * context of a client modifying the database (for instance when we delete a

Source from the content-addressed store, hash-verified

348 * just to notify the clients that are in the table for this key, that would
349 * otherwise miss the fact we are no longer tracking the key for them. */
350void trackingInvalidateKeyRaw(client *c, char *key, size_t keylen, int bcast) {
351 if (TrackingTable == NULL) return;
352
353 if (bcast && raxSize(PrefixTable) > 0)
354 trackingRememberKeyToBroadcast(c,key,keylen);
355
356 rax *ids = raxFind(TrackingTable,(unsigned char*)key,keylen);
357 if (ids == raxNotFound) return;
358
359 raxIterator ri;
360 raxStart(&ri,ids);
361 raxSeek(&ri,"^",NULL,0);
362 while(raxNext(&ri)) {
363 uint64_t id;
364 memcpy(&id,ri.key,sizeof(id));
365 client *target = lookupClientByID(id);
366 /* Note that if the client is in BCAST mode, we don't want to
367 * send invalidation messages that were pending in the case
368 * previously the client was not in BCAST mode. This can happen if
369 * TRACKING is enabled normally, and then the client switches to
370 * BCAST mode. */
371 if (target == NULL ||
372 !(target->flags & CLIENT_TRACKING)||
373 target->flags & CLIENT_TRACKING_BCAST)
374 {
375 continue;
376 }
377
378 /* If the client enabled the NOLOOP mode, don't send notifications
379 * about keys changed by the client itself. */
380 if (target->flags & CLIENT_TRACKING_NOLOOP &&
381 target == c)
382 {
383 continue;
384 }
385
386 sendTrackingMessage(target,key,keylen,0);
387 }
388 raxStop(&ri);
389
390 /* Free the tracking table: we'll create the radix tree and populate it
391 * again if more keys will be modified in this caching slot. */
392 TrackingTableTotalItems -= raxSize(ids);
393 raxFree(ids);
394 raxRemove(TrackingTable,(unsigned char*)key,keylen,NULL);
395}
396
397/* Wrapper (the one actually called across the core) to pass the key
398 * as object. */

Callers 2

trackingInvalidateKeyFunction · 0.85
trackingLimitUsedSlotsFunction · 0.85

Calls 12

raxSizeFunction · 0.85
raxFindFunction · 0.85
raxStartFunction · 0.85
raxSeekFunction · 0.85
raxNextFunction · 0.85
lookupClientByIDFunction · 0.85
sendTrackingMessageFunction · 0.85
raxStopFunction · 0.85
raxFreeFunction · 0.85
raxRemoveFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected