{"id":22428604,"url":"https://github.com/flc1125/php-queue","last_synced_at":"2025-11-03T14:03:01.278Z","repository":{"id":62505479,"uuid":"83027561","full_name":"flc1125/php-queue","owner":"flc1125","description":"PHP+redis队列","archived":false,"fork":false,"pushed_at":"2018-11-06T13:30:01.000Z","size":12,"stargazers_count":13,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-30T10:43:31.234Z","etag":null,"topics":["cli","job-queue","php","queue","redis"],"latest_commit_sha":null,"homepage":null,"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/flc1125.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-02-24T09:57:28.000Z","updated_at":"2023-08-02T13:59:47.000Z","dependencies_parsed_at":"2022-11-02T10:01:31.996Z","dependency_job_id":null,"html_url":"https://github.com/flc1125/php-queue","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flc1125%2Fphp-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flc1125%2Fphp-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flc1125%2Fphp-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flc1125%2Fphp-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flc1125","download_url":"https://codeload.github.com/flc1125/php-queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228363960,"owners_count":17908319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cli","job-queue","php","queue","redis"],"created_at":"2024-12-05T20:16:23.487Z","updated_at":"2025-11-03T14:02:56.236Z","avatar_url":"https://github.com/flc1125.png","language":"PHP","readme":"# php+redis消息队列\n\n## 环境\n\n- PHP \u003e= 5.4\n- composer\n\n## 安装\n\n```\ncomposer require flc/php-queue\n```\n\n## 使用范例\n\nproducer\n\n```php\n/**\n * 任务创建\n */\nrequire_once __DIR__ . '/bootstrap.php';\n\nuse Flc\\Queue\\Manager;\nuse Jobs\\Demo;\n\n// 创建工作\n$demo = new Demo('测试');\n\n// 推送到队列\nfor ($i = 0; $i \u003c= 100; $i ++) {\n    Manager::instance()-\u003epush($demo);\n}\n\necho Manager::instance()-\u003ecount();\n```\n\nconsumer\n\n```php\n/**\n * 任务执行者（常驻）\n */\nrequire_once __DIR__ . '/bootstrap.php';\n\nuse Flc\\Queue\\Manager;\nuse Jobs\\Demo;\n\nif ('cli' !== php_sapi_name()) {\n    die('必须在命令行模式下运行');\n}\n\nwhile (true) {\n    // 从队列拉取任务\n    $job = Manager::instance()-\u003epull();\n\n    // 如无任务，则休息2秒\n    if (! $job) {\n        sleep(2);\n        continue;\n    }\n\n    try {\n        call_user_func_array([$job, 'handle'], []);\n    } catch (Exception $e) {\n        echo $e-\u003egetMessage();\n    }\n}\n```\n\n## License\n\nMIT","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflc1125%2Fphp-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflc1125%2Fphp-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflc1125%2Fphp-queue/lists"}