PHPackages                             outman/dq - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. outman/dq

ActiveLibrary[Caching](/categories/caching)

outman/dq
=========

PHP delay queue based on Redis.

v1.0.1(8y ago)4171MITPHP

Since Feb 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/outman/dq)[ Packagist](https://packagist.org/packages/outman/dq)[ Docs](https://github.com/outman/dq)[ RSS](/packages/outman-dq/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

dq
==

[](#dq)

PHP delay queue based on Redis. Just For Study.

Install
-------

[](#install)

```
composer require outman/dq
```

Usage
-----

[](#usage)

### Client

[](#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 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

[](#server)

```
