mingalevme/illuminate-uqueue
最新稳定版本:1.2.1
Composer 安装命令:
composer require mingalevme/illuminate-uqueue
包简介
Laravel/Lumen uniqueable queues (Database, Redis)
README 文档
README
Provides support for uniqueable queues for Laravel/Lumen 5.5+.
Travis CI
Codecov
Supported drivers:
- Database
- Redis (Based on Sorted Sets)
Installation
-
composer require mingalevme/illuminate-uqueue -
In Laravel 5.5+, the service provider and facade will automatically get registered.
For older versions of the framework or Lumen, follow the steps below:
Register the appropriate service provider
\Mingalevme\Illuminate\UQueue\LaravelUQueueServiceProvider::classor\Mingalevme\Illuminate\UQueue\LumenUQueueServiceProvider::class. -
If you plan to use the database as a driver you should add the migration (change the table name if necessary):
<?php // /src/migrations/2017_01_01_000002_jobs_add_uniqueable.php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class JobsAddUniqueable extends Migration { /** * Run the migrations. * * @return void */ public function up() { if (!Schema::hasColumn('jobs', 'unique_id')) { Schema::table('jobs', function($table) { $table->string('unique_id')->nullable(); $table->unique(['queue', 'unique_id'], 'jobs_queue_unique_id_unique'); }); } } /** * Reverse the migrations. * * @return void */ public function down() { if (Schema::hasColumn('jobs', 'unique_id')) { Schema::table('jobs', function (Blueprint $table) { $table->dropUnique('jobs_queue_unique_id_unique'); $table->dropColumn('unique_id'); }); } } }
- Create a job that implements the interface
\Mingalevme\Illuminate\UQueue\Jobs\Uniqueable:
<?php namespace App\Jobs; use Mingalevme\Illuminate\UQueue\Jobs\Uniqueable; class ExampleJob implements Uniqueable { protected $data; public function __construct(array $data) { ksort($data); $this->data = $data; } public function uniqueable() { return md5(json_encode($this->data)); } public function handle() { // ... } }
统计信息
- 总下载量: 45.91k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 21
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-09-26