vkoori/identifier-queue

该包最新版本(1.1.1)没有可用的许可证信息。

此包用于处理具有标识字段以进行搜索的队列。

1.1.1 2023-06-17 11:09 UTC

This package is auto-updated.

Last update: 2024-09-17 14:01:23 UTC


README

composer require vkoori/identifier-queue

注册服务提供商

Luemn

将以下行添加到 bootstrap/app.php 文件中。

$app->register(\Kooriv\Queue\Providers\QueueServiceProvider::class);

Laravel

对于5.5之前的Laravel版本或未使用自动发现的情况,请在config/app.php中注册服务提供商

添加连接到config/queue.php

'identify' => [
    'driver' => 'identify',
    'table' => 'identify_jobs',
    'queue' => 'default',
    'retry_after' => 90,
    'after_commit' => false,
]

创建数据库表

php artisan queue:identifier-table

php artisan migrate

注意

此表完全兼容Lumen/Laravel数据库驱动。因此,使用此表时不必担心。

分发任务

您可以使用以下辅助函数在队列中分发任务

dispatcher(new ExampleJob)->onConnection("identify")->onQueue("queue")->setIdentifier("identifier");

注意

如果您想设置 identifierCode,则您的任务必须使用以下特质

use \Kooriv\Queue\Illuminate\Bus\Trait\IdentifierCode;

注意

使用此辅助函数不会对其他驱动造成损害。