PHPackages                             amtgard/redis-set-queue - 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. amtgard/redis-set-queue

ActiveLibrary

amtgard/redis-set-queue
=======================

Redis message SetQueue backed by workerman

v1.1.1(9mo ago)013MITPHPPHP &gt;=8.1

Since Aug 10Pushed 9mo ago2 watchersCompare

[ Source](https://github.com/amtgard/redis-set-queue)[ Packagist](https://packagist.org/packages/amtgard/redis-set-queue)[ Docs](https://github.com/amtgard/redis-set-queue)[ RSS](/packages/amtgard-redis-set-queue/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (6)Used By (0)

[![Code Climate](https://camo.githubusercontent.com/f49ebef9e71efe1b897c2129c7402b7218bacecfcef19dc01c7eca36244baa9d/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f616d74676172642f72656469732d7365742d71756575652f6261646765732f6770612e737667)](https://codeclimate.com/github/amtgard/redis-set-queue)

redis-set-queue
===============

[](#redis-set-queue)

A setqueue built on top of redis

Usage
-----

[](#usage)

This library is designed to be used with a cron or worker library, such as [workerman](https://github.com/walkor/workerman) (`composer require workerman/workerman`).

It operates as a general pub/sub queue with the following trick: if any key is already in the queue, it will not be re-queued. When a duplicate key is requeued, the default operation is to return the existing message without replacement.

`send()` with the optional `$replace = true` parameter will replace the existing message with the new message.

In either case, no more than a single message will ever exist for the same key at the same time.

##### \[NOTE: Key idempotency is best-effort. There are conditions in which messages are evicted or duplicated.\]

[](#note-key-idempotency-is-best-effort-there-are-conditions-in-which-messages-are-evicted-or-duplicated)

General use is enshrined in code in the `RedisPubSubQueueTest.php` test file, but in general use is expected from two systems:

1. Publishers
2. Subscribers

### Subscriber Setup

[](#subscriber-setup)

```
$config = new RedisDataStructureConfig();
$config->setConfig([
    'host' => '127.0.0.1',
    'port' => 36379,
]);
$redis = new Redis();
$redis->pconnect($config->getConfig()['host'], $config->getConfig()['port']);

$publisherName = "TEST";
$readDelay = 100; // microseconds

if ($redis->isConnected()) {
    $hashSetFactory = new RedisHashSetFactory();
    $redrivableQueueFactory = new RedisRedrivableQueueFactory();
    $queue = new SetQueue($publisherName, $config, $hashSetFactory, $redrivableQueueFactory);

    $pubSub = new PubSubQueue();
    $pubSub->addQueue($queue);
    $pubSub->redrive($queue->getName());

    $callCount = 0;
    $handle = $pubSub->subscribe($queue->getName(), function($key, $message) use (&$callCount) {
        if ($message == "MESSAGE1") {
            $callCount++;
        }
    });

    do {
        $pubSub->pump($handle);
        // Run every 100 milliseconds
        usleep($readDelay * 1000);
    } while (true);
}
```

### Publisher Setup

[](#publisher-setup)

```
$config = new RedisDataStructureConfig();
$config->setConfig([
    'host' => '127.0.0.1',
    'port' => 36379,
]);
$redis = new Redis();
$redis->pconnect($config->getConfig()['host'], $config->getConfig()['port']);

$publisherName = "TEST";

if ($redis->isConnected()) {
    $hashSetFactory = new RedisHashSetFactory();
    $redrivableQueueFactory = new RedisRedrivableQueueFactory();
    $queue = new SetQueue($publisherName, $config, $hashSetFactory, $redrivableQueueFactory);

    $pubSub = new PubSubQueue();
    $handle = $pubSub->addQueue($queue);

    $pubSub->send($handle, "KEY1", "MESSAGE1");
}
```

Building &amp; Testing
----------------------

[](#building--testing)

Built and tested on PHP 8.3 &amp; 8.4 with Redis extensions.

You may need to install and configure Redis extensions:

`pecl install redis`

To test all methods, you will need to run Redis locally (and modify tests) or run the provided docker file to set up a test server.

`docker compose -f docker-compose-php8-setqueue.dev.yml up -d --build`

Then run:

`./vendor/bin/phpunit`

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance58

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~180 days

Total

3

Last Release

278d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b6d7e891827c823a1d8bbef786eb928fe33647f76f0ae469c3bea4757b51888?d=identicon)[amtgard](/maintainers/amtgard)

---

Top Contributors

[![esdraelon](https://avatars.githubusercontent.com/u/7896847?v=4)](https://github.com/esdraelon "esdraelon (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/amtgard-redis-set-queue/health.svg)

```
[![Health](https://phpackages.com/badges/amtgard-redis-set-queue/health.svg)](https://phpackages.com/packages/amtgard-redis-set-queue)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
