outman/dq
Composer 安装命令:
composer require outman/dq
包简介
PHP delay queue based on Redis.
关键字:
README 文档
README
PHP delay queue based on Redis. Just For Study.
Install
composer require outman/dq
Usage
Client
require __DIR__ . '/vendor/autoload.php'; $redisParams = [ 'scheme' => 'tcp', 'host' => '127.0.0.1', 'port' => 6379, ]; $config = [ 'params' => $redisParams // Predis/Client $params // 'options' => [] // Predis/Client $options // 'bucketCount' => DQ::DEFAULT_BUCKET_THREAD // 'queueName' => DQ::DEFAULT_QUEUE, // 'bucketPrefix' => DQ::DEFAULT_QUEUE_BUCKET, // 'partialCount' => DQ::HASH_PARTIAL, ]; $queue = new DQ\Client\Queue($config); $queue->enqueue(mixed $value [, int $delaySeconds = 0]); // $value will be serialize. //// enqueue delay for ($i = 0; $i <= 10000; $i ++) { mt_srand($i); $dt = mt_rand(0, 100);// delay time seconds. $ret = $queue->enqueue([ 'dq' => sprintf('delay value - %07d - %d', $i, $dt),], $dt); // if ($i % 10000) { // echo "TEST-", $i, PHP_EOL; // } } //// dequeue while (true) { $v = $queue->dequeue(); if ($v) { $v = json_encode($v) . PHP_EOL; file_put_contents('deq_1.txt', $v, FILE_APPEND); echo $v; } }
Server
<?php require __DIR__ . '/vendor/autoload.php'; $redisParams = [ 'scheme' => 'tcp', 'host' => '127.0.0.1', 'port' => 6379, ]; $config = [ 'params' => $redisParams, // Predis/Client $params // 'options' => [] // Predis/Client $options // 'bucketCount' => DQ::DEFAULT_BUCKET_THREAD // 'queueName' => DQ::DEFAULT_QUEUE, // 'bucketPrefix' => DQ::DEFAULT_QUEUE_BUCKET, // 'partialCount' => DQ::HASH_PARTIAL, ]; $scanner = new DQ\Server\Scanner($config); $scanner->run();
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-03