{"id":22425352,"url":"https://github.com/phppkg/queue","last_synced_at":"2026-04-01T19:18:37.850Z","repository":{"id":56991491,"uuid":"92901438","full_name":"phppkg/queue","owner":"phppkg","description":"A simple php queue library implements.","archived":false,"fork":false,"pushed_at":"2019-02-01T02:28:24.000Z","size":38,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-03-28T00:58:07.783Z","etag":null,"topics":["library","php-queue","priority-queue","queue"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phppkg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-31T03:42:34.000Z","updated_at":"2024-07-09T09:50:05.000Z","dependencies_parsed_at":"2022-08-21T10:10:43.657Z","dependency_job_id":null,"html_url":"https://github.com/phppkg/queue","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phppkg/queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fqueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fqueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fqueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fqueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phppkg","download_url":"https://codeload.github.com/phppkg/queue/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fqueue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","php-queue","priority-queue","queue"],"created_at":"2024-12-05T19:13:52.879Z","updated_at":"2026-04-01T19:18:37.827Z","avatar_url":"https://github.com/phppkg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php 的队列实现\n\nphp的队列使用包装, 默认自带支持 `高 high` `中 norm` `低 low` 三个级别的队列操作。\n\n- `DbQueue` 基于数据库(mysql/sqlite)的队列实现\n- `PhpQueue` 基于 php `SplQueue` 实现\n- `RedisQueue` 基于 redis 实现 - 操作具有原子性,并发操作不会有问题\n- `ShmQueue` 基于共享内存实现  - 操作会自动加锁,并发操作不会有问题\n- `SysVQueue` 基于 *nix 系统的 system v message 实现. php 需启用 `--enable-sysvmsg` 通常是默认开启的 :)\n\n## 安装\n\n- composer\n\n```json\n{\n    \"require\": {\n        \"inhere/queue\": \"dev-master\"\n    }\n}\n```\n\n- 直接拉取\n\n```bash\ngit clone https://gitee.com/inhere/php-queue.git // gitee\ngit clone https://github.com/inhere/php-queue.git // github\n```\n\n## 使用\n\n```php\n// file: example/queue.php\nuse Inhere\\Queue\\QueueInterface;\n\n// require __DIR__ . '/autoload.php';\n\n$q = \\Inhere\\Queue\\Queue::make([\n    'driver' =\u003e 'sysv', // shm sysv php\n    'id' =\u003e 12,\n]);\n//var_dump($q);\n\n$q-\u003epush('n1');\n$q-\u003epush('n2');\n$q-\u003epush(['n3-array-value']);\n$q-\u003epush('h1', QueueInterface::PRIORITY_HIGH);\n$q-\u003epush('l1', QueueInterface::PRIORITY_LOW);\n$q-\u003epush('n4');\n\n$i = 6;\n\nwhile ($i--) {\n    var_dump($q-\u003epop());\n    usleep(50000);\n}\n```\n\nrun `php example/queue.php`. output:\n\n```\n% php example/queue.php                                                                                                                                                     17-06-11 - 22:36:01\ndriver is sysv\nstring(2) \"h1\"\nstring(2) \"n1\"\nstring(2) \"n2\"\narray(1) {\n  [0] =\u003e\n  string(11) \"n3-array-value\"\n}\nstring(2) \"n4\"\nstring(2) \"l1\"\n```\n\n## 其他\n\nsystem v 内存查看：\n\n```bash\nipcs\nipcs -a // 命令可以查看当前使用的共享内存、消息队列及信号量所有信息\nipcs -p // 命令可以得到与共享内存、消息队列相关进程之间的消息\nipcs -u // 命令可以查看各个资源的使用总结信息\nipcs -q // 只查看消息队列\nipcs -qa // 查看消息队列，并显示更多信息\n```\n\n删除共享内存：\n\n```bash\n$ ipcrm\n\nusage: ipcrm [-q msqid] [-m shmid] [-s semid]\n             [-Q msgkey] [-M shmkey] [-S semkey] ...\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphppkg%2Fqueue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphppkg%2Fqueue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphppkg%2Fqueue/lists"}