mirror of
https://github.com/idanoo/php-resque.git
synced 2024-11-22 00:11:53 +00:00
Remove spaces from README code samples.
This commit is contained in:
parent
2d4458fbed
commit
14989b0e9e
110
README.md
110
README.md
@ -52,14 +52,13 @@ If you're not familiar with Composer, please see <http://getcomposer.org/>.
|
|||||||
1. Add php-resque to your application's composer.json.
|
1. Add php-resque to your application's composer.json.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
{
|
||||||
{
|
//...
|
||||||
...
|
"require": {
|
||||||
"require": {
|
"chrisboulton/php-resque": "1.2.x"
|
||||||
"chrisboulton/php-resque": "1.2.x"
|
},
|
||||||
},
|
// ...
|
||||||
...
|
}
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Run `composer install`.
|
2. Run `composer install`.
|
||||||
@ -68,7 +67,7 @@ If you're not familiar with Composer, please see <http://getcomposer.org/>.
|
|||||||
initialization file. (example)
|
initialization file. (example)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
```
|
```
|
||||||
|
|
||||||
## Jobs ##
|
## Jobs ##
|
||||||
@ -78,15 +77,13 @@ If you're not familiar with Composer, please see <http://getcomposer.org/>.
|
|||||||
Jobs are queued as follows:
|
Jobs are queued as follows:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
// Required if redis is located elsewhere
|
||||||
|
Resque::setBackend('localhost:6379');
|
||||||
|
|
||||||
// Required if redis is located elsewhere
|
$args = array(
|
||||||
Resque::setBackend('localhost:6379');
|
'name' => 'Chris'
|
||||||
|
);
|
||||||
$args = array(
|
Resque::enqueue('default', 'My_Job', $args);
|
||||||
'name' => 'Chris'
|
|
||||||
);
|
|
||||||
Resque::enqueue('default', 'My_Job', $args);
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Defining Jobs ###
|
### Defining Jobs ###
|
||||||
@ -94,16 +91,14 @@ Jobs are queued as follows:
|
|||||||
Each job should be in it's own class, and include a `perform` method.
|
Each job should be in it's own class, and include a `perform` method.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
class My_Job
|
||||||
class My_Job
|
{
|
||||||
{
|
public function perform()
|
||||||
public function perform()
|
{
|
||||||
{
|
// Work work work
|
||||||
// Work work work
|
echo $this->args['name'];
|
||||||
echo $this->args['name'];
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
When the job is run, the class will be instantiated and any arguments
|
When the job is run, the class will be instantiated and any arguments
|
||||||
@ -120,24 +115,23 @@ The `tearDown` method if defined, will be called after the job finishes.
|
|||||||
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
class My_Job
|
||||||
class My_Job
|
{
|
||||||
|
public function setUp()
|
||||||
{
|
{
|
||||||
public function setUp()
|
// ... Set up environment for this job
|
||||||
{
|
|
||||||
// ... Set up environment for this job
|
|
||||||
}
|
|
||||||
|
|
||||||
public function perform()
|
|
||||||
{
|
|
||||||
// .. Run job
|
|
||||||
}
|
|
||||||
|
|
||||||
public function tearDown()
|
|
||||||
{
|
|
||||||
// ... Remove environment for this job
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function perform()
|
||||||
|
{
|
||||||
|
// .. Run job
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
// ... Remove environment for this job
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Tracking Job Statuses ###
|
### Tracking Job Statuses ###
|
||||||
@ -151,15 +145,15 @@ To track the status of a job, pass `true` as the fourth argument to
|
|||||||
returned:
|
returned:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$token = Resque::enqueue('default', 'My_Job', $args, true);
|
$token = Resque::enqueue('default', 'My_Job', $args, true);
|
||||||
echo $token;
|
echo $token;
|
||||||
```
|
```
|
||||||
|
|
||||||
To fetch the status of a job:
|
To fetch the status of a job:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$status = new Resque_Job_Status($token);
|
$status = new Resque_Job_Status($token);
|
||||||
echo $status->get(); // Outputs the status
|
echo $status->get(); // Outputs the status
|
||||||
```
|
```
|
||||||
|
|
||||||
Job statuses are defined as constants in the `Resque_Job_Status` class.
|
Job statuses are defined as constants in the `Resque_Job_Status` class.
|
||||||
@ -191,15 +185,15 @@ not having a single environment such as with Ruby, the PHP port makes
|
|||||||
*no* assumptions about your setup.
|
*no* assumptions about your setup.
|
||||||
|
|
||||||
To start a worker, it's very similar to the Ruby version:
|
To start a worker, it's very similar to the Ruby version:
|
||||||
|
```sh
|
||||||
$ QUEUE=file_serve php bin/resque
|
$ QUEUE=file_serve php bin/resque
|
||||||
|
```
|
||||||
It's your responsibility to tell the worker which file to include to get
|
It's your responsibility to tell the worker which file to include to get
|
||||||
your application underway. You do so by setting the `APP_INCLUDE` environment
|
your application underway. You do so by setting the `APP_INCLUDE` environment
|
||||||
variable:
|
variable:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ QUEUE=file_serve APP_INCLUDE=../application/init.php php bin/resque
|
$ QUEUE=file_serve APP_INCLUDE=../application/init.php php bin/resque
|
||||||
```
|
```
|
||||||
|
|
||||||
*Pro tip: Using Composer? More than likely, you don't need to worry about
|
*Pro tip: Using Composer? More than likely, you don't need to worry about
|
||||||
@ -216,8 +210,8 @@ Setting `VERBOSE` will print basic debugging information and `VVERBOSE`
|
|||||||
will print detailed information.
|
will print detailed information.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ VERBOSE QUEUE=file_serve bin/resque
|
$ VERBOSE QUEUE=file_serve bin/resque
|
||||||
$ VVERBOSE QUEUE=file_serve bin/resque
|
$ VVERBOSE QUEUE=file_serve bin/resque
|
||||||
```
|
```
|
||||||
|
|
||||||
### Priorities and Queue Lists ###
|
### Priorities and Queue Lists ###
|
||||||
@ -230,7 +224,7 @@ checked in.
|
|||||||
As per the original example:
|
As per the original example:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ QUEUE=file_serve,warm_cache bin/resque
|
$ QUEUE=file_serve,warm_cache bin/resque
|
||||||
```
|
```
|
||||||
|
|
||||||
The `file_serve` queue will always be checked for new jobs on each
|
The `file_serve` queue will always be checked for new jobs on each
|
||||||
@ -242,7 +236,7 @@ All queues are supported in the same manner and processed in alphabetical
|
|||||||
order:
|
order:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ QUEUE=* bin/resque
|
$ QUEUE=* bin/resque
|
||||||
```
|
```
|
||||||
|
|
||||||
### Running Multiple Workers ###
|
### Running Multiple Workers ###
|
||||||
@ -251,7 +245,7 @@ Multiple workers ca be launched and automatically worked by supplying
|
|||||||
the `COUNT` environment variable:
|
the `COUNT` environment variable:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ COUNT=5 bin/resque
|
$ COUNT=5 bin/resque
|
||||||
```
|
```
|
||||||
|
|
||||||
### Custom prefix ###
|
### Custom prefix ###
|
||||||
@ -260,7 +254,7 @@ When you have multiple apps using the same Redis database it is better to
|
|||||||
use a custom prefix to separate the Resque data:
|
use a custom prefix to separate the Resque data:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ PREFIX=my-app-name bin/resque
|
$ PREFIX=my-app-name bin/resque
|
||||||
```
|
```
|
||||||
|
|
||||||
### Forking ###
|
### Forking ###
|
||||||
@ -308,7 +302,7 @@ and supplying a callback that you would like triggered when the event is
|
|||||||
raised:
|
raised:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
Resque_Event::listen('eventName', [callback]);
|
Resque_Event::listen('eventName', [callback]);
|
||||||
```
|
```
|
||||||
|
|
||||||
`[callback]` may be anything in PHP that is callable by `call_user_func_array`:
|
`[callback]` may be anything in PHP that is callable by `call_user_func_array`:
|
||||||
|
Loading…
Reference in New Issue
Block a user