studentjason / laravel-async-queue
为 Laravel/Oracle 提供的异步队列驱动程序(推送到后台)
v0.3.0
2014-11-26 07:59 UTC
Requires
- php: >=5.3.0
- illuminate/console: 4.x|5.0.x
- illuminate/support: 4.x|5.0.x
This package is not auto-updated.
Last update: 2024-09-24 15:45:44 UTC
README
将函数/闭包推送到后台。
与 'sync' 驱动类似,这并不是真正的队列驱动程序。它总是立即触发。唯一的区别是闭包被发送到后台,而不需要等待响应。这个包作为在不设置“真实”队列驱动程序的情况下运行后台任务的替代方案,更具可用性。
注意:如果您来自 0.1.0(或 dev-master),则需要运行迁移,因为新版本使用数据库来存储队列。
安装
使用 Composer 需求此包的最新版本
composer require studentjason/laravel-async-queue
将服务提供者添加到 config/app.php 文件中的 providers 数组
'Barryvdh\Queue\AsyncServiceProvider',
您需要为此包运行迁移
$ php artisan migrate --package="barryvdh/laravel-async-queue"
或者发布它们,以便它们被复制到您的常规迁移中
$ php artisan migrate:publish barryvdh/laravel-async-queue
现在您应该能够使用 config/queue.php 中的异步驱动程序
'default' => 'async',
'connections' => array(
...
'async' => array(
'driver' => 'async',
),
...
}
默认情况下,使用 php
作为 PHP 的二进制路径。您可以通过向队列配置添加 binary
选项来更改此设置。您还可以添加额外的参数(例如 HHVM)
'connections' => array(
...
'async' => array(
'driver' => 'async',
'binary' => 'php',
'binary_args' => '',
),
...
}
它应该与同步驱动程序一样工作,因此不需要运行队列监听器。缺点是实际上无法排队或计划事情。Queue::later() 也直接触发,但在后台仅运行 sleep($delay)
。有关更多信息,请参阅 https://laravel.net.cn/docs/queues