-
zhaozhao.zz authored
Currently, when the number of databases exceeds 16, the efficiency of cleaning expired keys is relatively low. The reason is that by default only 16 databases are scanned when attempting to clean expired keys (CRON_DBS_PER_CALL is 16). But users may set databases higher than 16, such as 256, but it does not necessarily mean that all 256 databases have expiration time set. If only one database has expiration time set, this database needs 16 activeExpireCycle rounds in order to be scanned once, and 15 of those rounds are meaningless. To optimize the efficiency of expiration in such scenarios, we use dbs_per_call to control the number of databases with expired keys being scanned. Additionally, add a condition to limit the maximum number of rounds to server.dbnum to prevent excessive spinning. This ensures that even if only one database has expired keys, it can be triggered within a single cron job.
1bd0b549