quantaforge / queue
QuantaForge 队列包。
v1.0.0
2023-10-14 14:41 UTC
Requires
- php: ^8.1
- quantaforge/collections: ^1.0.0
- quantaforge/console: ^1.0.0
- quantaforge/container: ^1.0.0
- quantaforge/contracts: ^1.0.0
- quantaforge/database: ^1.0.0
- quantaforge/filesystem: ^1.0.0
- quantaforge/pipeline: ^1.0.0
- quantaforge/serializable-closure: ^1.2.2
- quantaforge/support: ^1.0.0
- ramsey/uuid: ^4.7
- symfony/process: ^6.2
Suggests
- ext-filter: Required to use the SQS queue worker.
- ext-mbstring: Required to use the database failed job providers.
- ext-pcntl: Required to use all features of the queue worker.
- ext-pdo: Required to use the database queue worker.
- ext-posix: Required to use all features of the queue worker.
- aws/aws-sdk-php: Required to use the SQS queue driver and DynamoDb failed job storage (^3.235.5).
- pda/pheanstalk: Required to use the Beanstalk queue driver (^4.0).
- quantaforge/redis: Required to use the Redis queue driver (^10.0).
README
QuantaForge 队列组件为各种不同的队列服务提供了一个统一的 API。队列允许你延迟处理耗时任务,例如发送电子邮件,直到稍后时间,从而大大加快了应用程序的 Web 请求。
使用说明
首先,创建一个新的队列 Capsule
管理器实例。类似于为 Eloquent ORM 提供的 "Capsule",队列 Capsule 旨在使在 QuantaForge 框架之外使用库的配置尽可能简单。
use QuantaForge\Queue\Capsule\Manager as Queue; $queue = new Queue; $queue->addConnection([ 'driver' => 'beanstalkd', 'host' => 'localhost', 'queue' => 'default', ]); // Make this Capsule instance available globally via static methods... (optional) $queue->setAsGlobal();
一旦 Capsule 实例已注册,你可以这样使用它
// As an instance... $queue->push('SendEmail', ['message' => $message]); // If setAsGlobal has been called... Queue::push('SendEmail', ['message' => $message]);
有关使用队列的更多文档,请参阅 QuantaForge 框架文档。