slowmove/simple-php-queue
最新稳定版本:v0.4
Composer 安装命令:
composer require slowmove/simple-php-queue
包简介
A simple, primarily file based, queue with multiple adapters
README 文档
README
Simple file system based PHP queue, with multiple adapters.
Currently implemented
textfilesqliteredis(send in connection string instead of file path, default to localhost)beanstalkdhttps://beanstalkd.github.io/
Requirements
PHP 8.1+
Usage examples
Examples available to run here
Producer
<?php use Slowmove\SimplePhpQueue\Queue; use Slowmove\SimplePhpQueue\Storage\StorageType; $queue = new Queue(StorageType::SQLITE, "./queue.db"); for ($i = 0; $i < 150; $i++) { $queue->enqueue("test $i"); }
Consumer
<?php use Slowmove\SimplePhpQueue\Queue; use Slowmove\SimplePhpQueue\Storage\StorageType; $queue = new Queue(StorageType::SQLITE, "./queue.db", true); $queue->listen(function ($item) { echo $item . PHP_EOL; });
Types
Enum available here;
enum StorageType: string { case FILE = 'file'; case SQLITE = 'sqlite'; case REDIS = 'redis'; case BEANSTALKD = 'beanstalkd'; }
Methods
enqueue(string $data): booldequeue(): ?stringlisten(callable $fn, int $delayWhenEmpty = 5): voidlength(): intcontent(): array
统计信息
- 总下载量: 281
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-28