laravel/framework — pull request #6035 by mohitmamoria (2014-10-09 12:42:45+00:00)
Title: Allows redis queue to use user-defined connection

Laravel has fantastic support for variety of queues out of the box. But in case of Redis queues, there was no support to use a connection other than the 'default' one (those defined in `database.php` config file).

In production, application of considerable size would prefer to use a totally separate box of Redis for queues (to keep the good performance of cache and queues). This pull request allows users to define which connection to use for Redis queue in the `queue.php` config file, like so:

```php
'redis' => array(
'driver' => 'redis',
'connection' => 'default', // <------- new attribute here
'queue' => 'default',
),
```

Then, the `Illuminate/Queue/Connectors/RedisConnector.php` passes this new attribute in the constructor of `Illuminate\Queue\RedisQueue.php` (yes, we are first checking if the new attribute exists or not) . And instead of directly using `$this->redis` in the `RedisQueue.php`, we are now using `$this->getConnection()` method which has the following definition:

```php
/**
* Get the connection for the queue.
*
* @return \Predis\ClientInterface
*/
protected function getConnection()
{
return $this->redis->connection($this->connection);
}
```

The test are also fixed and everything is working fine.