{"id":20330549,"url":"https://github.com/mle86/php-wq-redis","last_synced_at":"2026-04-12T23:01:46.873Z","repository":{"id":57018152,"uuid":"92555050","full_name":"mle86/php-wq-redis","owner":"mle86","description":"A Redis adapter for WQ (https://github.com/mle86/php-wq)","archived":false,"fork":false,"pushed_at":"2018-11-01T19:33:40.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-14T15:23:28.799Z","etag":null,"topics":["php","php-library","redis","redis-client","redis-queue","work-queue","wq"],"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/mle86.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-26T23:16:14.000Z","updated_at":"2019-12-02T21:52:10.000Z","dependencies_parsed_at":"2022-08-22T11:30:55.568Z","dependency_job_id":null,"html_url":"https://github.com/mle86/php-wq-redis","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mle86%2Fphp-wq-redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mle86%2Fphp-wq-redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mle86%2Fphp-wq-redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mle86%2Fphp-wq-redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mle86","download_url":"https://codeload.github.com/mle86/php-wq-redis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241851233,"owners_count":20030961,"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":["php","php-library","redis","redis-client","redis-queue","work-queue","wq"],"created_at":"2024-11-14T20:16:38.422Z","updated_at":"2026-04-12T23:01:46.810Z","avatar_url":"https://github.com/mle86.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WQ-Redis  (`mle86/wq-redis`)\n\nThis package contains the PHP class\n\u003ccode\u003emle86\\WQ\\WorkServerAdapter\\\\\u003cb\u003eRedisWorkServer\u003c/b\u003e\u003c/code\u003e.\n\nIt supplements the\n[**mle86/wq**](https://github.com/mle86/php-wq) package\nby implementing its `WorkServerAdapter` interface.\n\nIt connects to a [Redis](https://redis.io/) server\nusing the [phpredis](https://pecl.php.net/package/redis) extension.\n\n\n# Version and Compatibility\n\nThis is\n**version 1.0.2**\nof `mle86/wq-redis`.\n\nIt was developed for\nversion 1.0.0\nof `mle86/wq`\nand should be compatible\nwith all of its future 1.x versions as well.\n\n\n# Installation and Dependencies\n\n```\n$ sudo apt install php-redis  # to install the phpredis extension\n$ composer require mle86/wq-redis\n```\n\nIt depends on PHP 7.1,\n[mle86/wq](https://github.com/mle86/php-wq),\nand the [phpredis](https://pecl.php.net/package/redis) extension.\n\n\n# Class reference\n\n(\u003ccode\u003eclass mle86\\WQ\\WorkServerAdapter\\\\\u003cb\u003eRedisWorkServer\u003c/b\u003e implements WorkServerAdapter\u003c/code\u003e)\n\nIt connects to a Redis server.\n\nBecause Redis does not have\ndelayed entries,\nreserved entries,\nor buried entries,\nthis class uses several custom workarounds\nto emulate those features.\n\nFor every `$workQueue` used,\nthis class will create multiple Redis keys:\n\n* \u003ccode\u003e\\_wq.\u003ci\u003e$workQueue\u003c/i\u003e\u003c/code\u003e  (ready jobs – List)\n* \u003ccode\u003e\\_wq\\_delay.\u003ci\u003e$workQueue\u003c/i\u003e\u003c/code\u003e  (delayed jobs – Ordered Set)\n* \u003ccode\u003e\\_wq\\_buried.\u003ci\u003e$workQueue\u003c/i\u003e\u003c/code\u003e  (buried jobs – List)\n\nThe delaying mechanism was inspired by\n[this StackOverflow response](http://stackoverflow.com/a/15016319).\n\n* \u003ccode\u003epublic function \u003cb\u003e__construct\u003c/b\u003e (\\Redis $serverConnection)\u003c/code\u003e  \n    Takes an already-configured `Redis` instance to work with.\n    Does not attempt to establish a connection itself –\n    use the `connect()` factory method for that instead\n    or do it with `Redis::connect()` prior to using this constructor.\n* \u003ccode\u003epublic function \u003cb\u003econnect\u003c/b\u003e ($host = \"localhost\", $port = 6379, $timeout = 0.0, $retry\\_interval = 0)\u003c/code\u003e  \n    Factory method.\n    This will create a new `Redis` instance by itself.  \n    See [`Redis::connect()`](https://github.com/phpredis/phpredis#connect-open) for the parameter descriptions.\n\nInterface methods\nwhich are documented in the [`WorkServerAdapter`](https://github.com/mle86/php-wq/blob/master/doc/Ref_WorkServerAdapter_interface.md) interface:\n\n* \u003ccode\u003epublic function \u003cb\u003estoreJob\u003c/b\u003e (string $workQueue, Job $job, int $delay = 0)\u003c/code\u003e\n* \u003ccode\u003epublic function \u003cb\u003egetNextQueueEntry\u003c/b\u003e ($workQueue, int $timeout = DEFAULT\\_TIMEOUT) : ?QueueEntry\u003c/code\u003e\n* \u003ccode\u003epublic function \u003cb\u003eburyEntry\u003c/b\u003e (QueueEntry $entry)\u003c/code\u003e\n* \u003ccode\u003epublic function \u003cb\u003erequeueEntry\u003c/b\u003e (QueueEntry $entry, int $delay, string $workQueue = null)\u003c/code\u003e\n* \u003ccode\u003epublic function \u003cb\u003edeleteEntry\u003c/b\u003e (QueueEntry $entry)\u003c/code\u003e\n\n\n# Usage example\n\n```php\n\u003c?php\nuse mle86\\WQ\\WorkServerAdapter\\RedisWorkServer;\nuse mle86\\WQ\\WorkProcessor;\nuse mle86\\WQ\\Job\\Job;\n\n$processor = new WorkProcessor( new RedisWorkServer(\"localhost\") );\n\nwhile (true) {\n    $processor-\u003eprocessNextJob(\"webhook\", function(Job $job) {\n        $job-\u003e...;\n    });\n}\n```\n\nThis executes all jobs available in the local Redis server's “`webhook`” queue, forever.\nIt will however abort if one of the jobs throws an exception –\nyou might want to add a logging try-catch block around the `processNextJob()` call\nas shown in [WQ's “Quick Start” example](https://github.com/mle86/php-wq#quick-start).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmle86%2Fphp-wq-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmle86%2Fphp-wq-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmle86%2Fphp-wq-redis/lists"}