davelip/laravel-database-queue
Composer 安装命令:
composer require davelip/laravel-database-queue
包简介
README 文档
README
Push a function/closure to the Database queue.
This is a real queue driver, like beanstalkd or redis one. You need a daemon like supervisor or similar to listen to your queue.
Install
Add the package to the require section of your composer.json and run composer update
"davelip/laravel-database-queue": ">0.5"
Add the Service Provider to the providers array in config/app.php
'Davelip\Queue\DatabaseServiceProvider'
I suggest to publish migrations, so they are copied to your regular migrations
$ php artisan migrate:publish davelip/laravel-database-queue
And then run migrate
$ php artisan migrate
I suggest to create the failed_jobs table, in this moment, with:
$ php artisan queue:failed-table
You should now be able to use the database driver in config/queue.php
'default' => 'database',
'connections' => array(
...
'database' => array(
'driver' => 'database',
'queue' => 'queue-name', // optional, can be null or any string
'lock_type' => 0, // optional, can be 0, 1 or 2
),
...
}
It work in the same as beanstalkd or redis queue listener.
Listen for new job:
$ php artisan queue:listen
Concurrency are managed by status column in the queues table, so you can parallelize your queue:listen.
Atomicity of status change are garantee by database transaction, if you are having problems of race condition
can You set the option lock_type to:
- 'lock_type' => 1 // queue system will use sharedLock
- 'lock_type' => 2 // queue system will use lockForUpdate
see http://laravel.com/docs/4.2/queries#pessimistic-locking for further info.
Laravel Queue System
For more info see http://laravel.com/docs/queues
Thanks
Loosely based on https://github.com/barryvdh/laravel-async-queue
davelip/laravel-database-queue 适用场景与选型建议
davelip/laravel-database-queue 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 92.55k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2014 年 11 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 davelip/laravel-database-queue 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 davelip/laravel-database-queue 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 92.55k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-19