class AtomicThumbnailStream implements IteratorAggregate (View source)

Class AtomicThumbnailStream Outputs a stream of thumbnails in an atomic way. This ensures a thumbnail will only be built on a single thread at a time

Properties

protected DatabaseManager $manager
protected string $table
protected string $lockColumn
protected string $lockTimeoutColumn
protected string $isBuiltColumn
protected int $timeout
protected string $lockID

Methods

__construct(DatabaseManager $manager)

No description

Generator|void
getIterator()

Get an iterator that outputs locked thumbnail rows

mixed
next(QueryBuilder $nextQuery)

Get the next matching thumbnail path row

bool
reserveNext(array $next, Connection $db)

Mark the next item as reserved

bool|mixed
matchingLock($lockID, array $next, Connection $db)

Find the row matching the passed criteria This is used to verify that we've successfully locked a row in the database.

bool
lockColumnsExist(Connection $db)

Check if the required lock columns have been added to the database.

setTimeout(string $timeout)

Set the timeout for the table lock in seconds

QueryBuilder
getNextQuery(QueryBuilder $qb)

No description

string
getLockID()

Get and memoize the current lock ID

Details

__construct(DatabaseManager $manager)

No description

Parameters

DatabaseManager $manager

Generator|void getIterator()

Get an iterator that outputs locked thumbnail rows

Return Value

Generator|void

private mixed next(QueryBuilder $nextQuery)

Get the next matching thumbnail path row

Parameters

QueryBuilder $nextQuery

Return Value

mixed

private bool reserveNext(array $next, Connection $db)

Mark the next item as reserved

Parameters

array $next
Connection $db

Return Value

bool

private bool|mixed matchingLock($lockID, array $next, Connection $db)

Find the row matching the passed criteria This is used to verify that we've successfully locked a row in the database.

Parameters

$lockID
array $next
Connection $db

Return Value

bool|mixed

private bool lockColumnsExist(Connection $db)

Check if the required lock columns have been added to the database.

This prevents people upgrading from seeing 500 errors in their logs.

Parameters

Connection $db

Return Value

bool

setTimeout(string $timeout)

Set the timeout for the table lock in seconds

Parameters

string $timeout

protected QueryBuilder getNextQuery(QueryBuilder $qb)

No description

Parameters

QueryBuilder $qb

Return Value

QueryBuilder

private string getLockID()

Get and memoize the current lock ID

Return Value

string