TTL is restricted to durations of days and hours, with day being
24 hours. Note that you may only specify only one of
days or hours fields, not both.
You may specify TTL as object such as { days: numDays } or
{ hours: numHours }, or if you are using duration of days
you can specify TTL as just a number indicating number of days, so using
e.g. opt.ttl = 5; is also allowed.
Sometimes you may may need to indicate explicitly that the record doesn't
expire. This is needed when you perform put operation on existing record
and want to remove its expiration. You may indicate no expiration
by setting days or hours of to Infinity (or just set TTL itself to
Infinity), or use constant DO_NOT_EXPIRE.
The record expiration time is determined as follows:
Records expire on day or hour boundaries, depending on which 'days' or
'hours' field is used. At the time of the write operation, the TTL
parameter is used to compute the record's expiration time by first
converting it from days (or hours) to milliseconds, and then adding it
to the current system time. If the resulting expiration time is not evenly
divisible by the number of milliseconds in one day (or hour), it is
rounded up to the nearest day (or hour). The day and hour boundaries (the
day boundary is at midnight) are considered in UTC time zone.
The minimum TTL that can be specified is 1 hour. Because of the rounding
behavior described above, the actual record duration will be longer than
specified in the TTL (because of rounding up).
Also note that using duration of days are recommended as it will result in
the least amount of storage overhead compared to duration of hours.
TTLUtil class provides functions to create and manage TTL
instances and convert between TTL and record expiration time.
Used to specify time to live (TTL) for rows provided to put and other put methods, such as putIfAbsent, putIfPresent and putIfVersion.
TTL is restricted to durations of days and hours, with day being 24 hours. Note that you may only specify only one of days or hours fields, not both. You may specify TTL as object such as { days: numDays } or { hours: numHours }, or if you are using duration of days you can specify TTL as just a number indicating number of days, so using e.g. opt.ttl = 5; is also allowed.
Sometimes you may may need to indicate explicitly that the record doesn't expire. This is needed when you perform put operation on existing record and want to remove its expiration. You may indicate no expiration by setting days or hours of to Infinity (or just set TTL itself to Infinity), or use constant DO_NOT_EXPIRE.
The record expiration time is determined as follows:
Records expire on day or hour boundaries, depending on which 'days' or 'hours' field is used. At the time of the write operation, the TTL parameter is used to compute the record's expiration time by first converting it from days (or hours) to milliseconds, and then adding it to the current system time. If the resulting expiration time is not evenly divisible by the number of milliseconds in one day (or hour), it is rounded up to the nearest day (or hour). The day and hour boundaries (the day boundary is at midnight) are considered in UTC time zone.
The minimum TTL that can be specified is 1 hour. Because of the rounding behavior described above, the actual record duration will be longer than specified in the TTL (because of rounding up).
Also note that using duration of days are recommended as it will result in the least amount of storage overhead compared to duration of hours.
TTLUtil class provides functions to create and manage TTL instances and convert between TTL and record expiration time.
See
TTLUtil