\Drupal\strata\Journal DatabaseJournal

A journal backed by a database table.

The default, and the one the test lane runs against, because it needs nothing beyond the database Drupal already has. A Redis-backed journal is faster on a busy site but is optional; this one is always available, which is what a capture path needs.

The append is a single INSERT with no read before it. The sequence comes from the table's serial column, so two concurrent requests get a total order without either of them locking anything.

Summary

Methods
Properties
Constants
__construct
append
read
trim
pending
pendingBytes
oldest
clear
No public properties found
TABLE
No protected methods found
No protected properties found
No protected constants found
No private methods found
database
No private constants found

Constant

TABLE

TABLE = 'strata_journal'

The table operations are appended to.

Properties

$database

$database : \Drupal\Core\Database\Connection

Type

Connection

Methods

__construct()

__construct(\Drupal\Core\Database\Connection  $database) : mixed

Constructs a journal.

Parameters

\Drupal\Core\Database\Connection $database

The database to append to.

Returns

mixed —

append()

append(\Drupal\strata\Journal\JournalOp  $operation, ?string  $payload = null) : \Drupal\strata\Journal\JournalOp

Appends an operation and its payload.

Parameters

\Drupal\strata\Journal\JournalOp $operation

The operation to append.

?string $payload

The value the operation captured, or NULL for an operation that carries none.

Returns

\Drupal\strata\Journal\JournalOp —

The operation as appended, carrying its assigned sequence.

read()

read(int  $limit = 5000) : list<array{operation: \Drupal\strata\Journal\JournalOp, payload: string|null}>

Reads a window of operations in capture order, oldest first.

Parameters

int $limit

Most operations to return.

Returns

list

Operations paired with their payloads.

trim()

trim(int  $throughSequence) : int

Removes every operation up to and including a sequence.

Parameters

int $throughSequence

The highest sequence to remove.

Returns

int —

How many operations were removed.

pending()

pending() : int

How many operations are waiting.

Returns

int —

The pending count.

pendingBytes()

pendingBytes() : int

Bytes of payload waiting.

Returns

int —

The pending payload total.

oldest()

oldest() : int|null

Unix microseconds of the oldest waiting operation.

Returns

int|null —

The microtime, or NULL when nothing is waiting.

clear()

clear() : int

Removes everything without flushing it.

Returns

int —

How many operations were removed.