The second argument was incremented in the Illuminate\Queue\Console\WorkCommand constructor in Ravel 6.x and later.
Prior to 6.x
/**
* Create a new queue work command.
*
* @param\Illuminate\Queue\Worker$worker
* @return void
*/
public function__construct(Worker$worker)
{
parent::__construct();
$this->worker=$worker;
}
6.x and later
/**
* Create a new queue work command.
*
* @param\Illuminate\Queue\Worker$worker
* @param\Illuminate\Contracts\Cache\Repository$cache
* @return void
*/
public function__construct(Worker$worker, Cache$cache)
{
parent::__construct();
$this->cache=$cache;
$this->worker=$worker;
}
If you look at sources earlier than 6.x, it seems that the cache was previously specified internally, and this is now configured externally.
protected function runWorker($connection,$queue)
{
$this->worker->setCache($this->larvel['cache']->driver());
return $this->worker->{$this->option('once'?'runNextJob':'daemon'}(
$connection, $queue, $this->gatherWorkerOptions()
);
}
I'd like to set this cache as the second argument of the constructor, where can I get that cache?
laravel
app('cache.store')
might be able to retrieve it.
This is because the registerQueueWorkCommand
method in the Illuminate\Foundation\Providers\ArtisanServiceProvider
class specifies:
use Illuminate\Queue\Console\WorkCommand as QueueWorkCommand;
// abbreviation
$this->app->singleton('command.queue.work', function($app){
return new QueueWorkCommand ($app['queue.worker'], $app['cache.store']);
});
© 2024 OneMinuteCode. All rights reserved.