chrisboulton/php-resque — pull request #199 by arturo-c (2014-06-27 17:35:21+00:00)
Title: Adding beforeEnqueue event on Resque enqueue.

This so that we can stop jobs from queuing up via Event Hooks, so that we can do something like this:

```php
class ResqueUniquePlugin {
public function beforeEnqueue($class, array $arguments, $queue) {
if (Resque::redis()->exists($arguments['unique_key'])) {
return FALSE;
}
Resque::redis()->set($arguments['unique_key'], '1');
return TRUE;
}

public function afterPerform(Resque_Job $job) {
if (Resque::redis()->exists($job->payload['args'][0]['unique_key'])) {
Resque::redis()->del($job->payload['args'][0]['unique_key']);
}
}

public function onFailure($exception, Resque_Job $job) {
if (Resque::redis()->exists($job->payload['args'][0]['unique_key'])) {
Resque::redis()->del($job->payload['args'][0]['unique_key']);
}
}
}
```