class DatabaseBatchRepository implements PrunableBatchRepository (View source)

Properties

protected BatchFactory $factory

The batch factory instance.

protected Connection $connection

The database connection instance.

protected string $table

The database table to use to store batch information.

Methods

__construct(BatchFactory $factory, Connection $connection, string $table)

Create a new batch repository instance.

Batch[]
get(int $limit = 50, mixed $before = null)

Retrieve a list of batches.

Batch|null
find(string $batchId)

Retrieve information about an existing batch.

store(PendingBatch $batch)

Store a new pending batch.

void
incrementTotalJobs(string $batchId, int $amount)

Increment the total number of jobs within the batch.

decrementPendingJobs(string $batchId, string $jobId)

Decrement the total number of pending jobs for the batch.

incrementFailedJobs(string $batchId, string $jobId)

Increment the total number of failed jobs for the batch.

int|null
updateAtomicValues(string $batchId, Closure $callback)

Update an atomic value within the batch.

void
markAsFinished(string $batchId)

Mark the batch that has the given ID as finished.

void
cancel(string $batchId)

Cancel the batch that has the given ID.

void
delete(string $batchId)

Delete the batch that has the given ID.

int
prune(DateTimeInterface $before)

Prune all of the entries older than the given date.

int
pruneUnfinished(DateTimeInterface $before)

Prune all of the unfinished entries older than the given date.

int
pruneCancelled(DateTimeInterface $before)

Prune all of the cancelled entries older than the given date.

mixed
transaction(Closure $callback)

Execute the given Closure within a storage specific transaction.

string
serialize(mixed $value)

Serialize the given value.

mixed
unserialize(string $serialized)

Unserialize the given value.

toBatch(object $batch)

Convert the given raw batch to a Batch object.

getConnection()

Get the underlying database connection.

void
setConnection(Connection $connection)

Set the underlying database connection.

Details

__construct(BatchFactory $factory, Connection $connection, string $table)

Create a new batch repository instance.

Parameters

BatchFactory $factory
Connection $connection
string $table

Batch[] get(int $limit = 50, mixed $before = null)

Retrieve a list of batches.

Parameters

int $limit
mixed $before

Return Value

Batch[]

Batch|null find(string $batchId)

Retrieve information about an existing batch.

Parameters

string $batchId

Return Value

Batch|null

Batch store(PendingBatch $batch)

Store a new pending batch.

Parameters

PendingBatch $batch

Return Value

Batch

void incrementTotalJobs(string $batchId, int $amount)

Increment the total number of jobs within the batch.

Parameters

string $batchId
int $amount

Return Value

void

UpdatedBatchJobCounts decrementPendingJobs(string $batchId, string $jobId)

Decrement the total number of pending jobs for the batch.

Parameters

string $batchId
string $jobId

Return Value

UpdatedBatchJobCounts

UpdatedBatchJobCounts incrementFailedJobs(string $batchId, string $jobId)

Increment the total number of failed jobs for the batch.

Parameters

string $batchId
string $jobId

Return Value

UpdatedBatchJobCounts

protected int|null updateAtomicValues(string $batchId, Closure $callback)

Update an atomic value within the batch.

Parameters

string $batchId
Closure $callback

Return Value

int|null

void markAsFinished(string $batchId)

Mark the batch that has the given ID as finished.

Parameters

string $batchId

Return Value

void

void cancel(string $batchId)

Cancel the batch that has the given ID.

Parameters

string $batchId

Return Value

void

void delete(string $batchId)

Delete the batch that has the given ID.

Parameters

string $batchId

Return Value

void

int prune(DateTimeInterface $before)

Prune all of the entries older than the given date.

Parameters

DateTimeInterface $before

Return Value

int

int pruneUnfinished(DateTimeInterface $before)

Prune all of the unfinished entries older than the given date.

Parameters

DateTimeInterface $before

Return Value

int

int pruneCancelled(DateTimeInterface $before)

Prune all of the cancelled entries older than the given date.

Parameters

DateTimeInterface $before

Return Value

int

mixed transaction(Closure $callback)

Execute the given Closure within a storage specific transaction.

Parameters

Closure $callback

Return Value

mixed

protected string serialize(mixed $value)

Serialize the given value.

Parameters

mixed $value

Return Value

string

protected mixed unserialize(string $serialized)

Unserialize the given value.

Parameters

string $serialized

Return Value

mixed

protected Batch toBatch(object $batch)

Convert the given raw batch to a Batch object.

Parameters

object $batch

Return Value

Batch

Connection getConnection()

Get the underlying database connection.

Return Value

Connection

void setConnection(Connection $connection)

Set the underlying database connection.

Parameters

Connection $connection

Return Value

void