{"id":17955713,"url":"https://github.com/limingxinleo/x-swoole-queue","last_synced_at":"2025-03-25T02:30:58.539Z","repository":{"id":62517190,"uuid":"135108544","full_name":"limingxinleo/x-swoole-queue","owner":"limingxinleo","description":"基于Swoole的多进程消息队列","archived":false,"fork":false,"pushed_at":"2018-10-14T07:13:28.000Z","size":35,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T06:42:48.829Z","etag":null,"topics":["processes","queue","swoole"],"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/limingxinleo.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":"2018-05-28T04:13:20.000Z","updated_at":"2021-12-14T06:34:28.000Z","dependencies_parsed_at":"2022-11-02T13:45:51.043Z","dependency_job_id":null,"html_url":"https://github.com/limingxinleo/x-swoole-queue","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limingxinleo%2Fx-swoole-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limingxinleo%2Fx-swoole-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limingxinleo%2Fx-swoole-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limingxinleo%2Fx-swoole-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/limingxinleo","download_url":"https://codeload.github.com/limingxinleo/x-swoole-queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245385309,"owners_count":20606644,"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":["processes","queue","swoole"],"created_at":"2024-10-29T10:31:51.962Z","updated_at":"2025-03-25T02:30:58.191Z","avatar_url":"https://github.com/limingxinleo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swoole Queue Library\n\n[![Build Status](https://travis-ci.org/limingxinleo/x-swoole-queue.svg?branch=master)](https://travis-ci.org/limingxinleo/x-swoole-queue)\n\n## 安装\n~~~\ncomposer require limingxinleo/x-swoole-queue\n~~~\n\n## 基本使用办法\n消息队列使用\n~~~php\n\u003c?php\nuse Xin\\Swoole\\Queue\\Job;\n\n$config = include TESTS_PATH . '/_ci/config.php';\n\n$host = $config['redisHost'];\n$auth = $config['redisAuth'];\n$db = $config['redisDb'];\n$port = $config['redisPort'];\n\n$queue = new Job();\n$queue-\u003esetRedisConfig($host, $auth, $db, $port)\n    -\u003esetPidPath(TESTS_PATH . 'queue2.pid')\n    -\u003erun();\n~~~\n消息类\n~~~php\n\u003c?php\nnamespace Tests\\Test\\App;\n\nuse Xin\\Support\\File;\nuse Xin\\Swoole\\Queue\\JobInterface;\n\nclass TestJob implements JobInterface\n{\n    public $data;\n\n    public $file = TESTS_PATH . '/test.cache';\n\n    public function __construct($data)\n    {\n        $this-\u003edata = $data;\n    }\n\n    public function handle()\n    {\n        File::getInstance()-\u003eput($this-\u003efile, $this-\u003edata);\n    }\n}\n~~~\n载入消费队列的方法\n~~~php\n\u003c?php\nuse Tests\\Test\\App\\TestJob;\nuse Xin\\Redis;\n\n$redis = Redis::getInstance(); \n$job = new TestJob('upgrade by test job!');\n$redis-\u003elPush('swoole:queue:queue', serialize($job));\n~~~\n\n## 高级使用办法\n实现我们自己的消息队列类\n~~~php\n\u003c?php\nnamespace Tests\\Test\\App;\n\nuse Xin\\Swoole\\Queue\\Job;\n\nclass Queue extends Job\n{\n    public function __construct()\n    {\n        $config = include TESTS_PATH . '/_ci/config.php';\n\n        $host = $config['redisHost'];\n        $auth = $config['redisAuth'];\n        $db = $config['redisDb'];\n        $port = $config['redisPort'];\n\n        $this-\u003esetRedisConfig($host, $auth, $db, $port);\n        $this-\u003esetPidPath(TESTS_PATH . '/queue2.pid');\n    }\n}\n~~~\n\n启动我们的消息队列\n~~~php\n\u003c?php\nrequire __DIR__ . '/bootstrap.php';\n\nuse Tests\\Test\\App\\Queue;\n\n$config = include TESTS_PATH . '/_ci/config.php';\n\n$host = $config['redisHost'];\n$auth = $config['redisAuth'];\n$db = $config['redisDb'];\n$port = $config['redisPort'];\n\n$queue = new Queue();\n$queue-\u003erun();\n~~~\n\n载入消费数据\n~~~php\n\u003c?php\nuse Tests\\Test\\App\\Queue;\nuse Xin\\Swoole\\Queue\\JobInterface;\n\nclass TestJob implements JobInterface\n{\n    public $msg;\n\n    public function __construct($msg)\n    {\n        $this-\u003emsg = $msg;\n    }\n\n    public function handle()\n    {\n        echo $this-\u003emsg;\n    }\n}\n\n$job = new TestJob('upgrade by test job, when the queue push it!');\n$queue = new Queue();\n$queue-\u003epush($job);\n~~~","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimingxinleo%2Fx-swoole-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flimingxinleo%2Fx-swoole-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimingxinleo%2Fx-swoole-queue/lists"}