暂时仅支持
database
、redis
以及file
驱动
# composer.json
"minimum-stability": "dev",
"prefer-stable": true,
$ composer require "al-one/laravel-queue-replaceable" -vvv
# config/queue.php
<?php
return [
'default' => env('QUEUE_DRIVER','replaceable_database'),
'connections' => [
'replaceable_database' => [
'driver' => 'replaceable_database',
'connection' => 'mysql', // database connection
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
],
'replaceable_redis' => [
'driver' => 'replaceable_redis',
'connection' => 'default', // redis connection
'queue' => 'default',
'retry_after' => 90,
],
'replaceable_file' => [
'driver' => 'replaceable_file', // composer require al-one/laravel-queue-file
//'path' => 'app/queue', // use storage_path() if not start with "/"
//'queue' => 'default',
],
],
];
<?php
namespace App\Jobs;
class ProcessPodcast implements ShouldQueue
{
public function getReplaceableId()
{
return 'replaceable-id';
}
}
<?php
use App\Jobs\ProcessPodcast;
ProcessPodcast::dispatch($podcast)
->onConnection('replaceable_database')
->delay(now()->addMinutes(10));
MIT