Add per-db average TTL information in INFO output.

Example:

db0:keys=221913,expires=221913,avg_ttl=655

The algorithm uses a running average with only two samples (current and
previous). Keys found to be expired are considered at TTL zero even if
the actual TTL can be negative.

The TTL is reported in milliseconds.
This commit is contained in:
antirez
2013-08-06 15:00:43 +02:00
parent 4befe73b60
commit 112fa47978
2 changed files with 30 additions and 4 deletions

View File

@ -400,6 +400,7 @@ typedef struct redisDb {
dict *ready_keys; /* Blocked keys that received a PUSH */
dict *watched_keys; /* WATCHED keys for MULTI/EXEC CAS */
int id;
long long avg_ttl; /* Average TTL, just for stats */
} redisDb;
/* Client MULTI/EXEC state */