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

Function enableTracking

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

Enable the tracking state for the client 'c', and as a side effect allocates * the tracking table if needed. If the 'redirect_to' argument is non zero, the * invalidation messages for this client will be sent to the client ID * specified by the 'redirect_to' argument. Note that if such client will * eventually get freed, we'll send a message to the original client to * inform it of the condit

Source from the content-addressed store, hash-verified

178 * inform it of the condition. Multiple clients can redirect the invalidation
179 * messages to the same client ID. */
180void enableTracking(client *c, uint64_t redirect_to, uint64_t options, robj **prefix, size_t numprefix) {
181 if (!(c->flags & CLIENT_TRACKING)) server.tracking_clients++;
182 c->flags |= CLIENT_TRACKING;
183 c->flags &= ~(CLIENT_TRACKING_BROKEN_REDIR|CLIENT_TRACKING_BCAST|
184 CLIENT_TRACKING_OPTIN|CLIENT_TRACKING_OPTOUT|
185 CLIENT_TRACKING_NOLOOP);
186 c->client_tracking_redirection = redirect_to;
187
188 /* This may be the first client we ever enable. Create the tracking
189 * table if it does not exist. */
190 if (TrackingTable == NULL) {
191 TrackingTable = raxNew();
192 PrefixTable = raxNew();
193 TrackingChannelName = createStringObject("__redis__:invalidate",20);
194 }
195
196 /* For broadcasting, set the list of prefixes in the client. */
197 if (options & CLIENT_TRACKING_BCAST) {
198 c->flags |= CLIENT_TRACKING_BCAST;
199 if (numprefix == 0) enableBcastTrackingForPrefix(c,"",0);
200 for (size_t j = 0; j < numprefix; j++) {
201 sds sdsprefix = prefix[j]->ptr;
202 enableBcastTrackingForPrefix(c,sdsprefix,sdslen(sdsprefix));
203 }
204 }
205
206 /* Set the remaining flags that don't need any special handling. */
207 c->flags |= options & (CLIENT_TRACKING_OPTIN|CLIENT_TRACKING_OPTOUT|
208 CLIENT_TRACKING_NOLOOP);
209}
210
211/* This function is called after the execution of a readonly command in the
212 * case the client 'c' has keys tracking enabled and the tracking is not

Callers 1

clientCommandFunction · 0.85

Calls 4

raxNewFunction · 0.85
sdslenFunction · 0.85
createStringObjectFunction · 0.70

Tested by

no test coverage detected