From 842b44dc46cc143fb28f8cadbff1fda9c81e09e2 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 22 Jul 2019 12:29:54 +0200 Subject: [PATCH] Client side caching: call the invalidation functions always. Otherwise what happens is that the tracking table will never get garbage collected if there are no longer clients with tracking enabled. Now the invalidation function immediately checks if there is any table allocated, otherwise it returns ASAP, so the overhead when the feature is not used should be near zero. --- src/db.c | 4 ++-- src/expire.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/db.c b/src/db.c index 568e0b8de..cc31a117b 100644 --- a/src/db.c +++ b/src/db.c @@ -412,12 +412,12 @@ long long dbTotalServerKeyCount() { void signalModifiedKey(redisDb *db, robj *key) { touchWatchedKey(db,key); - if (server.tracking_clients) trackingInvalidateKey(key); + trackingInvalidateKey(key); } void signalFlushedDb(int dbid) { touchWatchedKeysOnFlush(dbid); - if (server.tracking_clients) trackingInvalidateKeysOnFlush(dbid); + trackingInvalidateKeysOnFlush(dbid); } /*----------------------------------------------------------------------------- diff --git a/src/expire.c b/src/expire.c index b23117a3c..598b27f96 100644 --- a/src/expire.c +++ b/src/expire.c @@ -64,7 +64,7 @@ int activeExpireCycleTryExpire(redisDb *db, dictEntry *de, long long now) { dbSyncDelete(db,keyobj); notifyKeyspaceEvent(NOTIFY_EXPIRED, "expired",keyobj,db->id); - if (server.tracking_clients) trackingInvalidateKey(keyobj); + trackingInvalidateKey(keyobj); decrRefCount(keyobj); server.stat_expiredkeys++; return 1;