{"id":13474195,"url":"https://github.com/gabfl/redis-priority-queue","last_synced_at":"2025-03-26T21:30:48.696Z","repository":{"id":43464998,"uuid":"76683335","full_name":"gabfl/redis-priority-queue","owner":"gabfl","description":"Simple Redis work queue with added features (priorities, pop multiple items at once)","archived":true,"fork":false,"pushed_at":"2023-05-09T00:16:09.000Z","size":82,"stargazers_count":41,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-21T06:05:46.535Z","etag":null,"topics":["lua","queue","redis","redis-queue"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/gabfl.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}},"created_at":"2016-12-16T20:25:38.000Z","updated_at":"2024-10-03T16:05:35.000Z","dependencies_parsed_at":"2024-01-13T18:24:18.277Z","dependency_job_id":"d928bcd2-b06c-4d20-bfde-ceb9761aeca0","html_url":"https://github.com/gabfl/redis-priority-queue","commit_stats":{"total_commits":43,"total_committers":2,"mean_commits":21.5,"dds":"0.37209302325581395","last_synced_commit":"3b08a47f5ccd842345949bbf411f3ac1739aeadc"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabfl%2Fredis-priority-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabfl%2Fredis-priority-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabfl%2Fredis-priority-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabfl%2Fredis-priority-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gabfl","download_url":"https://codeload.github.com/gabfl/redis-priority-queue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245738496,"owners_count":20664289,"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":["lua","queue","redis","redis-queue"],"created_at":"2024-07-31T16:01:10.262Z","updated_at":"2025-03-26T21:30:48.388Z","avatar_url":"https://github.com/gabfl.png","language":"Python","readme":"# redis-priority-queue\n\n[![Pypi](https://img.shields.io/pypi/v/rpq.svg)](https://pypi.org/project/rpq)\n[![Build Status](https://github.com/gabfl/redis-priority-queue/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/gabfl/redis-priority-queue/actions)\n[![codecov](https://codecov.io/gh/gabfl/redis-priority-queue/branch/main/graph/badge.svg)](https://codecov.io/gh/gabfl/redis-priority-queue)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://raw.githubusercontent.com/gabfl/redis-priority-queue/main/LICENSE)\n\nredis-priority-queue is a simple work queue similar to [Redis lists](https://redis.io/commands#list) with the following added features:\n\n - An item can be added with a priority (between -9007199254740992 and 9007199254740992)\n - Queues are automatically de-duplicated (duplicate items are voided when pushing them)\n - Multiple items can be popped from the queue at the same time\n - A [queue monitoring tool](#queue-monitoring) to easily see how many items are in each queue\n\nredis-priority-queue is based on [Redis sorted sets](https://redis.io/commands#sorted_set) and all sorted sets commands can be used alongside this project.\n\n## Clients\n\n - [Python client](clients/python/)\n - [PHP client](clients/php/)\n\n## Basic usage\n\n### Bash example\n\n```\n-- Generic\nredis-cli --eval src/redis-priority-queue.lua null null , [push|pop|peek|count] my_list (arg1, arg2...)\n\n-- Push an item\nredis-cli --eval src/redis-priority-queue.lua null null , push my_super_list my_item\n\n-- Pop an item\nredis-cli --eval src/redis-priority-queue.lua null null , pop my_super_list\n```\n\n## `push`: Push an item in a queue\n\n### Usage\n`push my_list item [(int) priority (default: 100)]`\n\n### Examples\n\n```\n-- Push an item with the default priority (100)\npush my_super_list my_item\n\n-- Push an item with a priority of 200\npush my_super_list my_item 200\n```\n\n### Return\n\nOutput is similar to [ZADD](https://redis.io/commands/zadd)\n\n## `pop`: Pop an item from the queue\n\n### Usage\n`pop my_list [(string) asc/desc (default: 'desc')] [(int) numer_of_items (default: 1')]`\n\n### Examples\n\n```\n-- Pop 1 item ordered by descending priority\npop my_super_list\n\n-- Pop 1 item ordered by ascending priority\npop my_super_list asc\n\n-- Pop 5 items ordered by descending priority\npop my_super_list desc 5\n```\n\n### Return\n\nOutput is similar to [ZRANGEBYSCORE](https://redis.io/commands/zrangebyscore)\n\n## `peek`: View a set of items from the list\nAliases: `list`, `view`\n\n### Usage\n\nSame as `pop` but items are not removed from the list.\n\n## `count`: Count items in a queue\n\nAlias: `size`\n\n### Usage\n\n`count my_list [(int) priority_min] [(int) priority_max]`\n\n### Examples\n\n```\n-- Count all items from the list\ncount my_super_list\n\n-- Count all items with a priority between 1 and 1110\ncount my_super_list 1 1110\n```\n\n### Return\n\nOutput is similar to [ZCOUNT](https://redis.io/commands/zcount)\n\n## Queue monitoring\n\nThe queues can be easily monitored with the Python script `src/queue_monitor.py`\n\nTo use the queue monitor, you need to ensure python is installed and use the following command:\n```\n# Installation\npip3 install rpq\n\n# Usage\nrpq_monitor\n```\n\n### Usage example\n\n```\n# Basic usage\nrpq_monitor -H [host] -p [port] (-a [auth] -n [dbnum])\n+-------------------+-------+-----------+----------+\n| Queue name        | Total | Up to 100 | From 101 |\n+-------------------+-------+-----------+----------+\n| book_orders       |    44 |        12 |       32 |\n| book_recycle      |   223 |       123 |      100 |\n| book_returns      |    13 |        13 |        0 |\n| late_fees_pending |   112 |        56 |       56 |\n| new_books         | 1,144 |     1,120 |       24 |\n+-------------------+-------+-----------+----------+\n\n# Specify your own groups\nrpq_monitor -H [host] -p [port] (-a [auth] -n [dbnum]) -s \"[[0, 1000], [1001, 2000], [2001, 3000]]\"\n+-------------------+-------+------------+----------------+----------------+\n| Queue name        | Total | 0 to 1,000 | 1,001 to 2,000 | 2,001 to 3,000 |\n+-------------------+-------+------------+----------------+----------------+\n| book_orders       |    44 |         24 |              9 |             11 |\n| book_recycle      |   223 |        127 |             40 |             56 |\n| book_returns      |    13 |         13 |              0 |              0 |\n| late_fees_pending |   112 |         58 |             13 |             41 |\n| new_books         | 1,144 |      1,142 |              2 |              0 |\n+-------------------+-------+------------+----------------+----------------+\n```\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabfl%2Fredis-priority-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabfl%2Fredis-priority-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabfl%2Fredis-priority-queue/lists"}