Skip to content

Commit c85bf23

Browse files
authored
Reset average ttl when empty databases (redis#8106)
On FLUSHDB or full sync, reset old average TTL stat. This Stat is incrementally collected by the master over time when it searches for expired keys.
1 parent 04056b7 commit c85bf23

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/db.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ long long emptyDbGeneric(redisDb *dbarray, int dbnum, int flags, void(callback)(
416416
dictEmpty(dbarray[j].dict,callback);
417417
dictEmpty(dbarray[j].expires,callback);
418418
}
419+
/* Because we will start a new database, reset average ttl. */
420+
dbarray[j].avg_ttl = 0;
421+
dbarray[j].expires_cursor = 0;
419422
}
420423

421424
/* Post-flush actions */

0 commit comments

Comments
 (0)