From d1adc85aa6f53424fec29751cec4bb3042a25359 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 13 Dec 2016 16:02:29 +0100 Subject: [PATCH] INFO: show num of slave-expires keys tracked. --- src/expire.c | 6 ++++++ src/server.c | 6 ++++-- src/server.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/expire.c b/src/expire.c index f590237b7..b05bf9f14 100644 --- a/src/expire.c +++ b/src/expire.c @@ -334,6 +334,12 @@ void rememberSlaveKeyWithExpire(redisDb *db, robj *key) { dictSetUnsignedIntegerVal(de,dbids); } +/* Return the number of keys we are tracking. */ +size_t getSlaveKeyWithExpireCount(void) { + if (slaveKeysWithExpire == NULL) return 0; + return dictSize(slaveKeysWithExpire); +} + /* Remove the keys in the hash table. We need to do that when data is * flushed from the server. We may receive new keys from the master with * the same name/db and it is no longer a good idea to expire them. diff --git a/src/server.c b/src/server.c index 4d204027c..0dc62c2b0 100644 --- a/src/server.c +++ b/src/server.c @@ -3008,7 +3008,8 @@ sds genRedisInfoString(char *section) { "pubsub_channels:%ld\r\n" "pubsub_patterns:%lu\r\n" "latest_fork_usec:%lld\r\n" - "migrate_cached_sockets:%ld\r\n", + "migrate_cached_sockets:%ld\r\n" + "slave_expires_tracked_keys:%zu\r\n", server.stat_numconnections, server.stat_numcommands, getInstantaneousMetric(STATS_METRIC_COMMAND), @@ -3027,7 +3028,8 @@ sds genRedisInfoString(char *section) { dictSize(server.pubsub_channels), listLength(server.pubsub_patterns), server.stat_fork_time, - dictSize(server.migrate_cached_sockets)); + dictSize(server.migrate_cached_sockets), + getSlaveKeyWithExpireCount()); } /* Replication */ diff --git a/src/server.h b/src/server.h index 0bd344e9d..5d3be585a 100644 --- a/src/server.h +++ b/src/server.h @@ -1734,6 +1734,7 @@ void activeExpireCycle(int type); void expireSlaveKeys(void); void rememberSlaveKeyWithExpire(redisDb *db, robj *key); void flushSlaveKeysWithExpireList(void); +size_t getSlaveKeyWithExpireCount(void); /* evict.c -- maxmemory handling and LRU eviction. */ void evictionPoolAlloc(void);