TTL (time-to-live) Options

TTL background thread frequency

—ttl.frequency

The frequency for invoking the TTL background removal thread. The value for thisoption is specified in milliseconds.The lower this value, the more frequently the TTL background thread will kick inand scan all available TTL indexes for expired documents, and the earlier theexpired documents will actually be removed.

TTL maximum total removals

—ttl.max-total-removes

In order to avoid “random” load spikes by the background thread suddenly kicking in and removing a lot of documents at once, the number of to-be-removed documentsper thread invocation can be capped.

The TTL background thread will go back to sleep once it has removed the configurednumber of documents in one iteration. If more candidate documents are left forremoval, they will be removed in following runs of the background thread.

TTL maximum per-collection removals

—ttl.max-collection-removes

This option controls the maximum number of documents to be removed per collectionin each background thread run. This value can be configured separately from thetotal removal amount so that the per-collection time window for locking and potentialwrite-write conflicts can be reduced.

TTL only for loaded collections

—ttl.only-loaded-collection

This option will only scan TTL indexes of collections that are already loaded intomemory. Setting the option to false will make the background thread ignore collectionsthat are currently not loaded. This saves the background thread from loading allcollections into memory.

This option is useful for the MMFiles engine only, where collections need to beloaded into memory first. For the RocksDB engine, collections do not need to be loadedinto memory first, so this option does not make any difference.