Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 3.1.0 (2026-05-20)
- Reduce redis calls across php-resque
- Reduce N+1 issues in queue lookup loop
- Remove status logic. Unusable at scale. (Removed 4th param in enqueue/create)

# 3.0.0 (2026-05-04)
- Update PHP to >=8.3
- Update packages
Expand Down
25 changes: 8 additions & 17 deletions HOWITWORKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@ What happens when you call `Resque::enqueue()`?
3. `\Resque\Job::create()` generates a job ID (a "token" in most of the docs)
4. `\Resque\Job::create()` pushes the job to the requested queue (first
argument)
5. `\Resque\Job::create()`, if status monitoring is enabled for the job (fourth
argument), calls `\Resque\Job\Status::create()` with the job ID as its only
argument
6. `\Resque\Job\Status::create()` creates a key in Redis with the job ID in its
name, and the current status (as well as a couple of timestamps) as its
value, then returns control to `\Resque\Job::create()`
7. `\Resque\Job::create()` returns control to `Resque::enqueue()`, with the job
5. `\Resque\Job::create()` returns control to `Resque::enqueue()`, with the job
ID as a return value
8. `Resque::enqueue()` triggers the `afterEnqueue` event, then returns control
6. `Resque::enqueue()` triggers the `afterEnqueue` event, then returns control
to your application, again with the job ID as its return value

## Workers At Work ##
Expand Down Expand Up @@ -72,8 +66,7 @@ How do the workers process the queues?
2. `\Resque\Worker::work()` calls `\Resque\Worker->workingOn()` with the new
`\Resque\Job` object as its argument
3. `\Resque\Worker->workingOn()` does some reference assignments to help keep
track of the worker/job relationship, then updates the job status from
`WAITING` to `RUNNING`
track of the worker/job relationship
4. `\Resque\Worker->workingOn()` stores the new `\Resque\Job` object's payload
in a Redis key associated to the worker itself (this is to prevent the job
from being lost indefinitely, but does rely on that PID never being
Expand All @@ -87,18 +80,17 @@ How do the workers process the queues?
2. If the exit status is not 0, the worker calls `\Resque\Job->fail()` with
a `Resque\Job\DirtyExitException` as its only argument.
3. `\Resque\Job->fail()` triggers an `onFailure` event
4. `\Resque\Job->fail()` updates the job status from `RUNNING` to `FAILED`
5. `\Resque\Job->fail()` calls `\Resque\Failure::create()` with the job
4. `\Resque\Job->fail()` calls `\Resque\Failure::create()` with the job
payload, the `Resque\Job\DirtyExitException`, the internal ID of the
worker, and the queue name as arguments
6. `\Resque\Failure::create()` creates a new object of whatever type has
5. `\Resque\Failure::create()` creates a new object of whatever type has
been set as the `\Resque\Failure` "backend" handler; by default, this is
a `ResqueFailureRedis` object, whose constructor simply collects the
data passed into `\Resque\Failure::create()` and pushes it into Redis
in the `failed` queue
7. `\Resque\Job->fail()` increments two failure counters in Redis: one for
6. `\Resque\Job->fail()` increments two failure counters in Redis: one for
a total count, and one for the worker
8. `\Resque\Job->fail()` returns control to the worker (still in
7. `\Resque\Job->fail()` returns control to the worker (still in
`\Resque\Worker::work()`) without a value
* Job
1. The job calls `\Resque\Worker->perform()` with the `\Resque\Job` as its
Expand Down Expand Up @@ -138,8 +130,7 @@ How do the workers process the queues?
`\Resque\Worker->perform()`; any other situation returns the value
`TRUE` along with control, instead
17. The `try...catch` block in `\Resque\Worker->perform()` ends
18. `\Resque\Worker->perform()` updates the job status from `RUNNING` to
`COMPLETE`, then returns control, with no value, to the worker (again
18. `\Resque\Worker->perform()` returns control, with no value, to the worker (again
still in `\Resque\Worker::work()`)
19. `\Resque\Worker::work()` calls `exit(0)` to terminate the job process
cleanly
Expand Down
36 changes: 0 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,42 +153,6 @@ If no jobs are given, this method will dequeue all jobs matching the provided qu
Resque::dequeue('default');
```

### Tracking Job Statuses ###

php-resque has the ability to perform basic status tracking of a queued
job. The status information will allow you to check if a job is in the
queue, is currently being run, has finished, or has failed.

To track the status of a job, pass `true` as the fourth argument to
`Resque::enqueue`. A token used for tracking the job status will be
returned:

```php
$token = Resque::enqueue('default', '\App\MyJobClass', $args, true);
echo $token;
```

To fetch the status of a job:

```php
$status = new \Resque\Job_Status($token);
echo $status->get(); // Outputs the status
```

Job statuses are defined as constants in the `\Resque\Job_Status` class.
Valid statuses include:

* `\Resque\Job_Status::STATUS_WAITING` - Job is still queued
* `\Resque\Job_Status::STATUS_RUNNING` - Job is currently running
* `\Resque\Job_Status::STATUS_FAILED` - Job has failed
* `\Resque\Job_Status::STATUS_COMPLETE` - Job is complete
* `false` - Failed to fetch the status - is the token valid?

Statuses are available for up to 24 hours after a job has completed
or failed, and are then automatically expired. A status can also
forcefully be expired by calling the `stop()` method on a status
class.

## Workers ##

Workers work in the exact same way as the Ruby workers. For complete
Expand Down
84 changes: 48 additions & 36 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
],
];
if (empty($argv[2])) {
$jobId = \Resque\Resque::enqueue('default', $argv[1], $args, true);
$jobId = \Resque\Resque::enqueue('default', $argv[1], $args);
} else {
$jobId = \Resque\Resque::enqueue($argv[1], $argv[2], $args, true);
$jobId = \Resque\Resque::enqueue($argv[1], $argv[2], $args);
}

echo "Queued job " . $jobId . "\n\n";
2 changes: 1 addition & 1 deletion src/Resque/Job/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Factory implements FactoryInterface
* Create job factory
*
* @param $className
* @param array $args
* @param $args
* @param $queue
*
* @return \Resque\Job\JobInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Resque/Job/FactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface FactoryInterface
{
/**
* @param $className
* @param array $args
* @param $args
* @param $queue
*
* @return \Resque\Job\JobInterface
Expand Down
Loading