summaryrefslogtreecommitdiff
path: root/src/tracking.c
diff options
context:
space:
mode:
authorLuke Palmer <luke@lukepalmer.net>2020-07-15 13:53:41 -0400
committerGitHub <noreply@github.com>2020-07-15 10:53:41 -0700
commit5f716ea467d29059a89f90b6ccbdee5a60443200 (patch)
tree6d49fa81440e449219ee1b56a1dadfc4fe46db0b /src/tracking.c
parent9242ccf238cbed018eb3a7fa3a437618345dd52b (diff)
downloadredis-5f716ea467d29059a89f90b6ccbdee5a60443200.tar.gz
Send null for invalidate on flush (#7469)
Diffstat (limited to 'src/tracking.c')
-rw-r--r--src/tracking.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/tracking.c b/src/tracking.c
index 8c2dca7ba..2721de32a 100644
--- a/src/tracking.c
+++ b/src/tracking.c
@@ -198,9 +198,11 @@ void trackingRememberKeys(client *c) {
*
* In case the 'proto' argument is non zero, the function will assume that
* 'keyname' points to a buffer of 'keylen' bytes already expressed in the
- * form of Redis RESP protocol, representing an array of keys to send
- * to the client as value of the invalidation. This is used in BCAST mode
- * in order to optimized the implementation to use less CPU time. */
+ * form of Redis RESP protocol. This is used for:
+ * - In BCAST mode, to send an array of invalidated keys to all
+ * applicable clients
+ * - Following a flush command, to send a single RESP NULL to indicate
+ * that all keys are now invalid. */
void sendTrackingMessage(client *c, char *keyname, size_t keylen, int proto) {
int using_redirection = 0;
if (c->client_tracking_redirection) {
@@ -342,17 +344,19 @@ void trackingInvalidateKey(client *c, robj *keyobj) {
trackingInvalidateKeyRaw(c,keyobj->ptr,sdslen(keyobj->ptr),1);
}
-/* This function is called when one or all the Redis databases are flushed
- * (dbid == -1 in case of FLUSHALL). Caching keys are not specific for
- * each DB but are global: currently what we do is send a special
- * notification to clients with tracking enabled, invalidating the caching
- * key "", which means, "all the keys", in order to avoid flooding clients
- * with many invalidation messages for all the keys they may hold.
+/* This function is called when one or all the Redis databases are
+ * flushed (dbid == -1 in case of FLUSHALL). Caching keys are not
+ * specific for each DB but are global: currently what we do is send a
+ * special notification to clients with tracking enabled, sending a
+ * RESP NULL, which means, "all the keys", in order to avoid flooding
+ * clients with many invalidation messages for all the keys they may
+ * hold.
*/
void freeTrackingRadixTree(void *rt) {
raxFree(rt);
}
+/* A RESP NULL is sent to indicate that all keys are invalid */
void trackingInvalidateKeysOnFlush(int dbid) {
if (server.tracking_clients) {
listNode *ln;
@@ -361,7 +365,7 @@ void trackingInvalidateKeysOnFlush(int dbid) {
while ((ln = listNext(&li)) != NULL) {
client *c = listNodeValue(ln);
if (c->flags & CLIENT_TRACKING) {
- sendTrackingMessage(c,"",1,0);
+ sendTrackingMessage(c,shared.null[c->resp]->ptr,sdslen(shared.null[c->resp]->ptr),1);
}
}
}