{"id":37014802,"url":"https://github.com/altmetric/reliable-queue","last_synced_at":"2026-01-14T01:28:51.844Z","repository":{"id":56946425,"uuid":"67447893","full_name":"altmetric/reliable-queue","owner":"altmetric","description":"A PHP library for reliable queueing backed by Redis","archived":true,"fork":false,"pushed_at":"2023-09-25T10:04:21.000Z","size":26,"stargazers_count":2,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T05:41:41.999Z","etag":null,"topics":["queueing","redis"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/altmetric/reliable-queue","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/altmetric.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-05T20:07:19.000Z","updated_at":"2023-10-24T09:47:06.000Z","dependencies_parsed_at":"2024-11-24T12:19:30.521Z","dependency_job_id":null,"html_url":"https://github.com/altmetric/reliable-queue","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":0.2777777777777778,"last_synced_commit":"9875ce3f1478967308d09246c79e4858f494bac8"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/altmetric/reliable-queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altmetric%2Freliable-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altmetric%2Freliable-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altmetric%2Freliable-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altmetric%2Freliable-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/altmetric","download_url":"https://codeload.github.com/altmetric/reliable-queue/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altmetric%2Freliable-queue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["queueing","redis"],"created_at":"2026-01-14T01:28:51.307Z","updated_at":"2026-01-14T01:28:51.829Z","avatar_url":"https://github.com/altmetric.png","language":"PHP","readme":"# Reliable Queue [![Build Status](https://travis-ci.org/altmetric/reliable-queue.svg?branch=master)](https://travis-ci.org/altmetric/reliable-queue)\n\nA PHP library for reliable queueing backed by [Redis](http://redis.io/).\n\n**Current version:** 0.4.0  \n**Supported PHP versions:** 5.3, 5.4, 5.5, 5.6, 7\n\n## Installation\n\n```shell\n$ composer require altmetric/reliable-queue\n```\n\n## Usage\n\n```php\n\u003c?php\nuse Altmetric\\ReliableQueue;\nuse Altmetric\\ChunkedReliableQueue;\nuse Altmetric\\PriorityReliableQueue;\n\n$queue = new ReliableQueue('unique-worker-name', 'to-do-queue', $redis, $logger);\n$queue[] = 'some-work';\n$queue[] = 'some-more-work';\n\nforeach ($queue as $work) {\n    // Perform some action on each piece of work in the to-do-queue\n}\n\n$queue = new ChunkedReliableQueue('unique-worker-name', 100, 'to-do-queue', $redis, $logger);\n\nforeach ($queue as $chunk) {\n    // $chunk will be an array of up to 100 pieces of work\n}\n\n$queue = new PriorityReliableQueue('unique-worker-name', array('critical-queue', 'default-queue', 'low-priority-queue'), $redis, $logger);\n\nforeach ($queue as $name =\u003e $work) {\n    // $work will be popped from the queue $name in the priority order given\n}\n```\n\n## API Documentation\n\n### `public ReliableQueue::__construct(string $name, string $queue, Redis $redis, LoggerInterface $logger)`\n\n```php\n$queue = new \\Altmetric\\ReliableQueue('unique-worker-name', 'to-do-queue', $redis, $logger);\n```\n\nInstantiate a new reliable queue object with the following arguments:\n\n* `$name`: a unique `string` name for this worker so that we can pick up any\n  unfinished work in the event of a crash;\n* `$queue`: the `string` key of the list in Redis to use as the queue;\n* `$redis`: a [`Redis`](https://github.com/phpredis/phpredis) client object for\n  communication with Redis;\n* `$logger`: a\n  [`Psr\\Log\\LoggerInterface`](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)-compliant\n  logger.\n\nThe returned object implements both the\n[`Iterator`](http://php.net/manual/en/class.iterator.php) (and therefore\n[`Traversable`](http://php.net/manual/en/class.traversable.php)) and\n[`ArrayAccess`](http://php.net/manual/en/class.arrayaccess.php) interface in\nPHP.\n\nThis means that it can be iterated over with `foreach`, yielding the queue name\nand a value on every iteration. Internally, the library will block for new work\nbut this is invisible from a client's perspective.\n\n```php\nforeach ($queue as $key =\u003e $work) {\n    // $key will be the queue key name in Redis\n    // $work will be the value popped from the queue\n}\n```\n\nYou can also modify the queue as if it were an array by using the typical array\noperations:\n\n```php\n$queue[] = 'work';  // enqueues work\n$queue[1];          // returns work at index 1 if it exists\n$queue[1] = 'work'; // sets work to index 1 in the queue\nunset($queue[1]);   // remove work at index 1 from the queue\n```\n\n### `public ChunkedReliableQueue::__construct(string $name, int $size, string $queue, Redis $redis, LoggerInterface $logger)`\n\n```php\n$queue = new \\Altmetric\\ChunkedReliableQueue('unique-worker-name', 100, 'to-do-queue', $redis, $logger);\n```\n\nInstantiate a new chunked, reliable queue object with the following arguments:\n\n* `$name`: a unique `string` name for this worker so that we can pick up any\n  unfinished work in the event of a crash;\n* `$size`: an integer maximum size of chunk to return on each iteration;\n* `$queue`: the `string` key of the list in Redis to use as the queue;\n* `$redis`: a [`Redis`](https://github.com/phpredis/phpredis) client object for\n  communication with Redis;\n* `$logger`: a\n  [`Psr\\Log\\LoggerInterface`](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)-compliant\n  logger.\n\nThe returned object implements the\n[`Iterator`](http://php.net/manual/en/class.iterator.php) (and therefore\n[`Traversable`](http://php.net/manual/en/class.traversable.php)) interface in\nPHP.\n\nThis means that it can be iterated over with `foreach`, yielding the queue name\nand an array of up to `$size` elements on every iteration. Internally, the\nlibrary will block for new work but this is invisible from a client's\nperspective.\n\nIf the queue contains sufficient items, the chunk of work will contain at most\n`$size` elements but if there is not enough work, it may return less (but\nalways at least 1 value).\n\n### `public PriorityReliableQueue:__construct(string $name, array $queues, Redis $redis, LoggerInterface $logger)`\n\n```php\n$queue = new \\Altmetric\\PriorityReliableQueue('unique-worker-name', array('critical-queue', 'default-queue', 'low-priority-queue'), $redis, $logger);\n```\n\nInstantiate a new priority-ordered, reliable queue object with the following arguments:\n\n* `$name`: a unique `string` name for this worker so that we can pick up any unfinished work in the event of a crash;\n* `$queues`: an `array` of `string` keys of lists in Redis to use as queues given in priority order;\n* `$redis`: a [`Redis`](https://github.com/phpredis/phpredis) client object for communication with Redis;\n* `$logger`: a\n  [`Psr\\Log\\LoggerInterface`](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)-compliant\n  logger.\n\nThe returned object implements the\n[`Iterator`](http://php.net/manual/en/class.iterator.php) (and therefore\n[`Traversable`](http://php.net/manual/en/class.traversable.php)) interface in\nPHP.\n\nThis means that it can be iterated over with `foreach`, yielding the queue name\nand a value on every iteration. Queues will be checked randomly for work based\non their priority order given in `$queues` meaning that the first queue will be\nchecked more often than the second, the second more than the third and so on.\nInternally, the library will repeatedly poll for new work but this is invisible\nfrom a client's perspective.\n\n```php\nforeach ($queue as $key =\u003e $work) {\n    // $key will be the queue key name in Redis\n    // $work will be the value popped from the queue\n}\n```\n\n## References\n\n* [Pattern: Reliable queue](http://redis.io/commands/rpoplpush#pattern-reliable-queue)\n\n## Acknowledgements\n\n* Thanks to [James Adam](https://github.com/lazyatom) for suggesting a way to\n  test the randomness of the priority queue.\n\n## License\n\nCopyright © 2016-2017 Altmetric LLP\n\nDistributed under the MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltmetric%2Freliable-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faltmetric%2Freliable-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltmetric%2Freliable-queue/lists"}