v0.7.0

Expiration

Last updated


This page explains how ToriiDB keys get a TTL and the points at which expired keys are removed.

Expiration


OperationResult
TTL(key)remaining seconds; -1 without expiry; -2 when missing or expired
Expire(key, seconds)ExpireAt = now + seconds
ExpireAt(key, ts)absolute timestamp
Persist(key)removes expiry

Expired keys are enforced at several points:
  • Get treats an expired entry as missing and deletes it from memory.
  • Keys, Find, Query, and VSearch skip expired entries.
  • A timer removes expired entries from every loaded database once per minute.
  • Compaction does not write expired entries to the new snapshot.

Write operations (Set with SetNX/SetXX, Del, Expire, ExpireAt, Persist, Incr, and the field writes) read the map directly without an expiry check, so an expired entry that has not been removed yet still counts as present for them until Get or the minute timer removes it.

中文