API / Minn\Runtime / CronTable

CronTable final class

Minn\Runtime\CronTable · public/minn/src/Minn/Runtime/CronTable.php · 133 lines

The cron option's shape, operated on as data: timestamp => hook => key => entry, kept in natural timestamp order. The key is the reference's own (a hash of the serialized argument list), so both stacks read one table.

Public

statickey(array $args): string#

The key an event's arguments hash to.

staticfromBlob(?string $blob): array#

The table read from the option's stored blob: the version marker dropped, timestamps in order, an unreadable or absent blob empty.

@return array<int, array<string, array<string, array<string, mixed>>>>
statichasNear(array $crons, int $timestamp, string $hook, string $key, int $window): bool#

Whether the same hook and arguments are already scheduled within the window around the timestamp.

staticinsert(array $crons, int $timestamp, string $hook, string $key, array $entry): array#

The table with an event added at a timestamp.

staticremove(array $crons, int $timestamp, string $hook, string $key): array#

The table with one event removed.

staticremoveHook(array $crons, string $hook): array#

The table with every event of a hook removed.

@return array{0: array, 1: int} the table without the hook, and how many entries went
statictimestampsFor(array $crons, string $hook, string $key): array#

When a hook and key are scheduled.

@return list<int> every timestamp the hook and arguments are scheduled at
staticfind(array $crons, string $hook, string $key, ?int $timestamp): ?array#

The entry for the hook and arguments at a timestamp, or at the next one when no timestamp is given, as [timestamp, entry].

staticnextRun(int $timestamp, int $interval, int $now): int#

The next run of a recurring event: one interval from now, aligned to the original timestamp when it is in the past.

staticdue(array $crons, int $now): array#

The timestamps at or before now, in order.