If replication is not enabled, the log-cleaning thread of the master deletes old logs using a configured TTL (Time To Live).
This TTL-based method does not work well with replication because archived logs that have exceeded their TTL may still be in a queue. The default behavior is augmented so that if a log is past its TTL, the cleaning thread looks up every queue until it finds the log. During this process, queues that are found are cached. If the log is not found in any queues, the log is deleted. The next time the cleaning process needs to look for a log, it starts by using its cached list.