If a table or view is assigned a TTL, its expiration timer will be reset to the value of its configured TTL each time it is accessed. For instance, a view with a five minute TTL will have its life extended by five minutes from the time it is accessed every time it is accessed. If it is not accessed within five minutes from the time of last access, it will be removed.
Tables, by default, will not expire. Views, by default, will expire in the number of minutes configured within the server's default_ttl setting.
A TTL can be any of the following:
- n - the database entity will live for n minutes since last access, where n is a positive integer
- 0 - the database entity will expire immediately
- -1 - the database entity will not expire
TTL only governs an entity's expiration by timeout. For example, a memory-only table with a TTL set to not expire will still be removed from the system upon database restart, as it is a non-persisted entity.
To assign a 7-minute TTL to a table, in Python:
To set a table to not expire, in Python: