Class: JobQueue

Implements a basic job queue for executing background tasks.

Usage:

// Post a task to be done
JobQueue::enqueue ('tube-name', ['data' => '...']);

// Look for tasks to be done
$worker = JobQueue::worker ();

$worker->watch ('tube-name')
$worker->ignore ('default');

while ($job = $worker->reserve ()) {
    $payload = $job->getData ();
    $data = json_decode ($payload);

    // Do something with $data

    $worker->delete ($job);
}

Properties

private static $backend

private static $service

Methods

private static conn ()

public static enqueue ($tube, $data)

Post a task to the queue.

public static worker ()

Return the job queue service that can be used to watch for tasks in the queue.