A wall-clock seam for memory writes.
The memory layer stamps updatedAt and expiresAt from a
MemoryClock, never from DateTime.now() directly. Production code
receives SystemMemoryClock; tests receive ManualMemoryClock so
expiry and ordering are deterministic and no test waits on real
time.
When to use
Pass a MemoryClock to MemoryCell.open (or remember) whenever a
test needs to control the passage of time. Stores take a now
parameter on the operations that need one (write, read,
purgeExpired) and the runtime supplies the clock's value.
How it works
The clock is a single now() function. ManualMemoryClock holds
the current instant and ManualMemoryClock.advance moves it; the
wall clock delegates to DateTime.now(). A clock has no timers and
never fires anything — scheduling lives in MemoryScheduler.
Non-obvious
- One clock, one timeline. A memory cell, its scheduler and its store must agree on time for expiry to be coherent. The runtime passes its clock to all three; a mixed wall/manual clock is a configuration bug.
- The clock is injected, not global. Two memory cells with two manual clocks can disagree on "now" in the same test, which is exactly what makes interleaving tests deterministic.
See also
- SystemMemoryClock — the production implementation.
- ManualMemoryClock — the deterministic test implementation.
MemoryScheduler— the timer seam, separate from the clock.
- Implementers
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
now(
) → DateTime - The current instant on this clock's timeline.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited