Expand description
Compact monotonic time utilities.
Uses a process-local monotonic clock for timestamps that are smaller
than std::time::Instant (8 bytes vs 16 bytes for Option
All internal expiry values are stored as monotonic milliseconds since
process start. Use monotonic_to_unix_ms to convert to wall-clock Unix
timestamps for commands like EXPIRETIME and PEXPIRETIME.
Constants§
- NO_
EXPIRY - Sentinel value meaning “no expiry”.
Functions§
- expiry_
from_ duration - Converts a Duration to an absolute expiry timestamp.
- is_
expired - Returns true if the given expiry timestamp has passed.
- monotonic_
to_ unix_ ms - Converts a monotonic expiry timestamp (ms since process start) to a Unix epoch timestamp in milliseconds.
- now_ms
- Returns current monotonic time in milliseconds since process start.
- now_
secs - Returns current monotonic time in seconds since process start, as u32.
- remaining_
ms - Returns remaining TTL in milliseconds, or None if no expiry.
- remaining_
secs - Returns remaining TTL in seconds, or None if no expiry.
- unix_
ms_ to_ monotonic_ ms - Converts a Unix epoch timestamp in milliseconds to a monotonic expiry
value suitable for storage in
Entry::expires_at_ms.