Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imroychen/php-async-queue
A simple asynchronous queue library.(一个简单php异步队列库)
https://github.com/imroychen/php-async-queue
async php-async-queue php-queue queue
Last synced: 28 days ago
JSON representation
A simple asynchronous queue library.(一个简单php异步队列库)
- Host: GitHub
- URL: https://github.com/imroychen/php-async-queue
- Owner: imroychen
- License: apache-2.0
- Created: 2021-09-10T16:18:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-13T15:44:57.000Z (almost 2 years ago)
- Last Synced: 2024-11-29T18:20:00.634Z (about 1 month ago)
- Topics: async, php-async-queue, php-queue, queue
- Language: PHP
- Homepage:
- Size: 44.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-EN.md
- License: LICENSE
Awesome Lists containing this project
README
[中文简体](README.md) / English
# Readme
A simple asynchronous queue library.
## Installation
composer require iry/queue## How to use
### 1. Queue configuration
>Create a class to implement the following methods。([Example](example/QueueConfig/SettingTest.php))
There can be multiple queues in a project, please create a configuration for each queue (Setting)
>
> Interface: [src/SettingInterface.php](src/SettingInterface.php)```php
namespace MyNamespace;//This is the namespace of your project
//
class MySetting extends \iry\queue\Setting{
function storage();
function tempPath(){}
//function beforeCreate($name, $client);// 任务入队前回调, return false 阻止任务继续入队
//function afterCreate($id);
//function i18n(){ return 'en-US'; } // en-US,zh-CN or file://.
}
```### 2.Create new task (client)
```php
use iry\queue\Client
Client::m(\MyNamespace\MySetting::class)->create($name,$args,$tags ,$execTime)
```
**create**(_$name, $args, $tags ,$execTime, $unique=true_) ([Example](./example/CreateTask.php))Parameter name|Type|Description
---|---|---
$name|string|Task name: (letters/numbers/ _) and other characters
$args|array|arguments .E.G:['id'=>123]
$tags|array|
$execTime|array|The execution time is used to delay the queue.### 3. Monitor and execute asynchronous tasks, only support CLI mode (server side)
```php
use iry\queue\Servicenew Service()->listen()
```
---
# 注:
## MySetting::storage
[Info](./src/Setting.php)[E.g.](./example/Queue2Config/MyDbStorage.php)