PHPackages                             inhere/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. [Queues &amp; Workers](/categories/queues)
4. /
5. inhere/queue

ActiveLibrary[Queues &amp; Workers](/categories/queues)

inhere/queue
============

queue library of the php

7172PHP

Since Feb 1Pushed 7y ago3 watchersCompare

[ Source](https://github.com/phppkg/queue)[ Packagist](https://packagist.org/packages/inhere/queue)[ RSS](/packages/inhere-queue/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

php 的队列实现
=========

[](#php-的队列实现)

php的队列使用包装, 默认自带支持 `高 high` `中 norm` `低 low` 三个级别的队列操作。

- `DbQueue` 基于数据库(mysql/sqlite)的队列实现
- `PhpQueue` 基于 php `SplQueue` 实现
- `RedisQueue` 基于 redis 实现 - 操作具有原子性,并发操作不会有问题
- `ShmQueue` 基于共享内存实现 - 操作会自动加锁,并发操作不会有问题
- `SysVQueue` 基于 \*nix 系统的 system v message 实现. php 需启用 `--enable-sysvmsg` 通常是默认开启的 :)

安装
--

[](#安装)

- composer

```
{
    "require": {
        "inhere/queue": "dev-master"
    }
}
```

- 直接拉取

```
git clone https://gitee.com/inhere/php-queue.git // gitee
git clone https://github.com/inhere/php-queue.git // github
```

使用
--

[](#使用)

```
// file: example/queue.php
use Inhere\Queue\QueueInterface;

// require __DIR__ . '/autoload.php';

$q = \Inhere\Queue\Queue::make([
    'driver' => 'sysv', // shm sysv php
    'id' => 12,
]);
//var_dump($q);

$q->push('n1');
$q->push('n2');
$q->push(['n3-array-value']);
$q->push('h1', QueueInterface::PRIORITY_HIGH);
$q->push('l1', QueueInterface::PRIORITY_LOW);
$q->push('n4');

$i = 6;

while ($i--) {
    var_dump($q->pop());
    usleep(50000);
}
```

run `php example/queue.php`. output:

```
% php example/queue.php                                                                                                                                                     17-06-11 - 22:36:01
driver is sysv
string(2) "h1"
string(2) "n1"
string(2) "n2"
array(1) {
  [0] =>
  string(11) "n3-array-value"
}
string(2) "n4"
string(2) "l1"

```

其他
--

[](#其他)

system v 内存查看：

```
ipcs
ipcs -a // 命令可以查看当前使用的共享内存、消息队列及信号量所有信息
ipcs -p // 命令可以得到与共享内存、消息队列相关进程之间的消息
ipcs -u // 命令可以查看各个资源的使用总结信息
ipcs -q // 只查看消息队列
ipcs -qa // 查看消息队列，并显示更多信息
```

删除共享内存：

```
$ ipcrm

usage: ipcrm [-q msqid] [-m shmid] [-s semid]
             [-Q msgkey] [-M shmkey] [-S semkey] ...
```

License
-------

[](#license)

MIT

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d23e1decaf354e8f36a7ad61128865dc78dd63336c2d023d79aa3ff8ba2a05ff?d=identicon)[inhere](/maintainers/inhere)

---

Top Contributors

[![inhere](https://avatars.githubusercontent.com/u/5302062?v=4)](https://github.com/inhere "inhere (22 commits)")

---

Tags

libraryphp-queuepriority-queuequeue

### Embed Badge

![Health badge](/badges/inhere-queue/health.svg)

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.3M26](/packages/league-geotools)[amphp/parser

A generator parser to make streaming parsers simple.

14952.8M16](/packages/amphp-parser)[amphp/serialization

Serialization tools for IPC and data storage in PHP.

13451.1M18](/packages/amphp-serialization)[enqueue/enqueue

Message Queue Library

19820.0M56](/packages/enqueue-enqueue)[deliciousbrains/wp-background-processing

WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks.

1.1k409.8k6](/packages/deliciousbrains-wp-background-processing)[react/async

Async utilities and fibers for ReactPHP

2238.8M171](/packages/react-async)

PHPackages © 2026

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