How to get all pending jobs in laravel queue on redis?

If someone is still looking for an answer, here is the way I did it:

$connection = null;
$default = 'default';

// For the delayed jobs
var_dump(
    \Queue::getRedis()
        ->connection($connection)
        ->zrange('queues:'.$default.':delayed', 0, -1)
);
    
// For the reserved jobs
var_dump(
    \Queue::getRedis()
        ->connection($connection)
        ->zrange('queues:'.$default.':reserved', 0, -1)
);

$connection is the Redis' connection name which is null by default, and the $default is the name of the queue which is default by default.


Since Laravel 5.3 you can simply use Queue::size() (see PR).

Tags:

Redis

Laravel