From e00442eb139c833f35406440a956e03679842034 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 22 Jul 2019 11:47:44 +0200 Subject: [PATCH] Clinet side caching: take count of used caching slots. --- src/tracking.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tracking.c b/src/tracking.c index 84b29d28a..5938efade 100644 --- a/src/tracking.c +++ b/src/tracking.c @@ -60,6 +60,7 @@ * use the most significant bits instead of the full 24 bits. */ #define TRACKING_TABLE_SIZE (1<<24) rax **TrackingTable = NULL; +unsigned long TrackingTableUsedSlots = 0; robj *TrackingChannelName; /* Remove the tracking state from the client 'c'. Note that there is not much @@ -109,8 +110,10 @@ void trackingRememberKeys(client *c) { sds sdskey = c->argv[idx]->ptr; uint64_t hash = crc64(0, (unsigned char*)sdskey,sdslen(sdskey))&(TRACKING_TABLE_SIZE-1); - if (TrackingTable[hash] == NULL) + if (TrackingTable[hash] == NULL) { TrackingTable[hash] = raxNew(); + TrackingTableUsedSlots++; + } raxTryInsert(TrackingTable[hash], (unsigned char*)&c->id,sizeof(c->id),NULL,NULL); } @@ -176,6 +179,7 @@ void trackingInvalidateKey(robj *keyobj) { * again if more keys will be modified in this hash slot. */ raxFree(TrackingTable[hash]); TrackingTable[hash] = NULL; + TrackingTableUsedSlots--; } void trackingInvalidateKeysOnFlush(int dbid) {