Skip to main content

Module time

Module time 

Source
Expand description

Time abstractions.

Cache logic must never read the wall clock directly (it would be untestable and non-deterministic). Instead, every timestamp flows from an injected Clock. This mirrors FusionCache’s use of DateTimeOffset.UtcNow.UtcTicks while keeping the domain pure: see the “Time” rule in the project guidelines.

Two distinct notions of time exist in a hybrid cache:

  • Logical / physical expiration within a node — handled by comparing Timestamps produced by the same Clock.
  • Cross-node ordering (backplane messages, tag markers, “newer wins”) — also a Timestamp, deliberately a wall-clock value so independent nodes can compare them.

Structs§

ManualClock
A manually-controlled clock for tests.
SystemClock
The real system clock, backed by SystemTime.
Timestamp
A point in time, measured in 100-nanosecond ticks since the Unix epoch.

Enums§

Timeout
A timeout that is either unbounded or a finite Duration.

Constants§

TICKS_PER_SECOND
Number of 100-nanosecond ticks in one second.

Traits§

Clock
Source of the current time.

Functions§

duration_to_ticks
Converts a Duration to 100ns ticks, saturating on overflow.
ticks_to_duration
Converts a non-negative tick count to a Duration.