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 31d0f34100
commit fa48b1fa32
2 changed files with 30 additions and 4 deletions

View File

@ -398,6 +398,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 */