DEFAULT_MAX_AGE
DEFAULT_MAX_AGE = 15
Seconds before a window is sealed.
Decides when a window of captured operations should be sealed into a segment.
The interval is a durability window, not a restore granularity. Operations inside a segment stay individually addressable and individually replayable, so a rollback reaches any single operation whatever the interval is. What the interval decides is how much is lost if the server dies before a flush.
It is also the dominant cost dial, and the cost is requests rather than bytes. Cloudflare R2 charges $4.50 per million Class A operations, and the segment count per month depends only on the interval, not on the site's size: one second costs 3,024,518 writes a month and is over the free tier on its own, while fifteen seconds costs 201,635 and is a fifth of it.
Three conditions therefore fire a flush, whichever comes first. Age bounds the loss window. Bytes bound the memory a request holds. Operations bound the work one flush does, so a burst does not produce a segment too large to seal inside a cron run.
__construct(int $maxAge = \self::DEFAULT_MAX_AGE, int $maxBytes = \self::DEFAULT_MAX_BYTES, int $maxOps = \self::DEFAULT_MAX_OPS) : mixed
Constructs a policy.
| int | $maxAge | Seconds before a flush. Zero means age never triggers one. |
| int | $maxBytes | Buffered payload bytes before a flush. Zero means size never triggers one. |
| int | $maxOps | Buffered operations before a flush. Zero means count never triggers one. |
When any bound is negative, or when all three are zero, which would mean a window is never sealed and the journal grows without limit.
shouldFlush(int $pending, int $bytes, int|null $oldest, int $now) : bool
Whether a window should be sealed now.
| int | $pending | Operations waiting. |
| int | $bytes | Payload bytes waiting. |
| int|null | $oldest | Unix microseconds of the oldest waiting operation, or NULL when nothing is waiting. |
| int | $now | Unix microseconds to compare against. |
TRUE when at least one bound has been reached.
reason(int $pending, int $bytes, int|null $oldest, int $now) : string|null
Which bound fired, for the log line and the timeline.
Age is checked first, then count, then size, so the reason reported is the one an operator is most likely to act on.
| int | $pending | Operations waiting. |
| int | $bytes | Payload bytes waiting. |
| int|null | $oldest | Unix microseconds of the oldest waiting operation, or NULL when nothing is waiting. |
| int | $now | Unix microseconds to compare against. |
One of "age", "operations" or "bytes", or NULL when no bound has been reached.
secondsUntilAge(int|null $oldest, int $now) : float
How long until the age bound fires, in seconds.
Surfaced so the UI can show the recovery-point lag rather than only reporting a flush after it has happened.
| int|null | $oldest | Unix microseconds of the oldest waiting operation, or NULL when nothing is waiting. |
| int | $now | Unix microseconds to compare against. |
Seconds remaining, 0.0 when the bound has passed, or INF when age never triggers a flush.
segmentsPerMonth() : float
Segment writes per month at this interval.
The figure the settings form shows next to the interval, because it is what the request bill is proportional to and it does not depend on the site's size.
Segments per 30.44-day month, or 0.0 when age never triggers a flush.