Static
Readonly
DO_Convenience constant to indicate that the row should not expire. It can be passed as TTL to a put operation to remove expiration from existing row.
Static
Readonly
MILLIS_Convenience constant representing number of milliseconds in 1 day.
Static
Readonly
MILLIS_Convenience constant representing number of milliseconds in 1 hour.
Static
fromConstructs TTL from absolute expiration time given reference time from which to measure record expration. TTL is computed as follows. First, expirationTime is rounded up to the nearest hour boundary. If inHours argument is specified, then the returned TTL will be in hours or days depending on whether inHours is true or false. If inHours is not specified, we check if the adjusted expiration time indicates midnight in UTC time zone, in which case the retured TTL will be in days, otherwise it will be in hours. Then, the duration is computed as the difference between the adjusted expiration time and the reference time rounded up to the nearest hour or day (depending on which is used in the returned TTL as described above) and TTL with that duration is returned. Note that if expiration time is before or equal to the reference time, it is possible that the returned value will contain 0 or negative duration, which indicates that the record has already expired.
TTL object
if expirationTime or referenceTime is invalid
Expiration time represented as Date or number of milliseconds since Unix epoch
Reference time represented as Date or number of milliseconds since Unix epoch
Optional
inHours: booleanWhether to return TTL in hours or days. If not specified, the unit of hours or days is determined as described above
Static
ofCreates TTL with duration of days
TTL object
if 'days' parameter is invalid
Number of days as positive integer or Infinity
Static
ofCreates TTL with duration of hours
TTL object
if 'hours' parameter is invalid
Number of hours as positive integer or Infinity
Static
toReturns the number of days in the TTL. If the TTL is specified in hours, the resulting days value is rounded down, which will result in 0 if TTL.hours < 24.
Number of days in the TTL object or Infinity
if TTL object is invalid
TTL object
Static
toConverts TTL to absolute expration time given the reference time from which to measure the expiration. The semantics follows the rounding behavior described in TimeToLive so that the returned value will be rounded up to the nearest hour or day boundary.
Expiration time as Date instance, may be invalid if ttl represents no expiration (Infinity)
if TTL object or referenceTime is invalid
TTL object
Reference time represented as Date or number of milliseconds since Unix epoch
Static
toConverts TTL to absolute expiration time in milliseconds since Unix epoch (January 1, 1970, 00:00:00 UTC). This method is the same as toExpirationTime returning time in milliseconds instead of as Date object.
Expiration time in milliseconds since Unix epoch or Infinity
if TTL object or referenceTime is invalid
TTL object
Reference time represented as Date or number of milliseconds since Unix epoch
Static
toReturns the number of hours in the TTL. If the TTL is specified in days, the return value is TTL.days * 24.
Number of hours in the TTL object or Infinity
if TTL object is invalid
TTL object
Static
toReturns number of milliseconds in the TTL. This is equivalent to toHours multiplied by MILLIS_IN_HOUR.
Number of milliseconds in the TTL object or Infinity
if TTL object is invalid
TTL object
Generated using TypeDoc
Classdesc
TTLUtil is a utility class that may be used to create and manage TimeToLive objects and convert between TTL and record expiration time. TTL behavior and relation to record expiration time is described in TimeToLive. Note that on input durations, TTL objects and expiration times are validated for correctness and NoSQLArgumentError is thrown if the representation is invalid.
See
TimeToLive