A PHP/Redis queue system based on Resque and PHP-Resque
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
extra Update phresqued Oct 8, 2014
src/Phresque terminate worker thread on kill button Oct 29, 2015
tests terminate worker thread on kill button Oct 29, 2015
.gitignore continue on repeated job Jan 13, 2015
.travis.yml phpunit tests Oct 6, 2014
README.md Update README.md Apr 8, 2015
composer.json additional tests Apr 24, 2015
phpunit.xml move version Oct 6, 2014

README.md

Phresque is a clustered queuing system for PHP with a redis backend, built from the ground up to provide bulletproof reliability.

Build Status Coverage Status

Creating a Job

// On the client
$phresque = new Phresque\Phresque();

// $phresque->make($class, $arguments = array());

$job = $phresque->make('ExampleJob', array('arg1' => 1,'arg2' => 'two'))
         ->in(10)          // Seconds to wait before executing (optional)
         ->lock()          // Don't allow another job of this name with the same arguments to run concurrently
         ->to('default');  // The job is now pushed to the queue 'default'. This should be the last method you call
// A sample job class - must be available on each worker
Class ExampleJob implements \Phresque\Job\JobInterface {
   
   protected $job;
   
   public function setJob(\Phresque\Model\Job $job)
   {
      $this->job = $job
   }
   
   public function perform()
   {
      var_dump($this->job->getArguments());
   }
}

Running Jobs

Create a script on the worker nodes containing the code below - run script multiple times or on multiple servers to create an array of worker nodes. Any free node will pick up the next job


// On the workers

$redisClient = new Irediscent\Irediscent(); // Or a compatible redis client of your choice eg. Predis\Client

$phresque = new Phresque\Phresque($redisClient);

$daemon = $this->phresque->worker('worker1'); // Hostname is used by default, but you can specify if required

$daemon->setLogger(new Monolog\Logger); // Optionally add a Psr\Log\LoggerInterface compatible logger

$daemon->run(); // Worker is now running

Insipration for parts of this library came from