{"id":19297570,"url":"https://github.com/limen/fastrq","last_synced_at":"2025-04-22T09:31:23.634Z","repository":{"id":57428692,"uuid":"158914873","full_name":"limen/fastrq","owner":"limen","description":"Queue, Stack and Priority Queue built on Redis.","archived":false,"fork":false,"pushed_at":"2019-08-09T03:19:58.000Z","size":31,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T23:17:27.228Z","etag":null,"topics":["lua","python","queue","redis","stack"],"latest_commit_sha":null,"homepage":"","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/limen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-11-24T07:59:37.000Z","updated_at":"2022-12-05T15:25:28.000Z","dependencies_parsed_at":"2022-09-02T16:39:15.378Z","dependency_job_id":null,"html_url":"https://github.com/limen/fastrq","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limen%2Ffastrq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limen%2Ffastrq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limen%2Ffastrq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limen%2Ffastrq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/limen","download_url":"https://codeload.github.com/limen/fastrq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250215161,"owners_count":21393746,"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","python","queue","redis","stack"],"created_at":"2024-11-09T23:05:20.461Z","updated_at":"2025-04-22T09:31:23.337Z","avatar_url":"https://github.com/limen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastrq - Queue, Stack and Priority Queue built on Redis\n\n[![Build Status](https://travis-ci.org/limen/fastrq.svg?branch=master)](https://travis-ci.org/limen/fastrq)\n\n[Wiki](https://github.com/limen/fastrq/wiki)\n\n[Fastrq for PHP](https://github.com/limen/fastrq-php)\n\n## Features\n\n+ Abstract Queue, Deque, Capped Queue/Deque, and Overflow-able Capped Queue/Deque\n+ Abstract Stack, Capped Stack\n+ Abstract Priority Queue, Capped Priority Queue and Overflow-able Capped Priority Queue\n+ Push and Pop support batch operation\n+ Using Lua scripts to save RTT (Round Trip Time)\n+ Support getting indexes of members \n+ Support pushing only if a member not already inside the queue\n+ Support pushing only if the queue already exists/not already exist\n+ All operations are `atomic`\n\n## Requirements\n\n- Redis \u003e=3.0.2\n- Python 2.7 or \u003e=3.4\n\n## Installation\n\nvia pip\n\n```\npip install fastrq\n```\n\nor from source\n\n```\npython setup.py install\n```\n\n## Usage\n\n```python\nfrom fastrq.queue import Queue, CappedQueue\nfrom fastrq.deque import Deque\nfrom fastrq.stack import Stack\nfrom fastrq.priorityqueue import PriorityQueue\n\n# queue\nq = Queue(\"fastrq_queue\")\nq.push(1)\nq.push([2, 3])\nq.push_ni(1) # got [3, False]. `ni` stands for `not inside`\nq.push_ae(1) # got 4. `ae` stands for `already exists`\nq.push_ne(1) # got False. `ne` stands for `not already exist`\nq.ttl(10)   # set the lifetime in seconds\nq.range(0, -1)  # got ['1', '2', '3']\nq.range(0, 1)  # got ['1', '2']\nq.indexof_one(1); # got 0\nq.indexof_one(2); # got 1\nq.indexof_one(4); # got None\nq.indexof_many([1, 2, 4]); # got {1: 0, 2: 1, 4: None}\n# push only if the member not inside the queue\nq.push_ni(4) # got [4, True]\nq.pop()\nq.pop(2)\nq.destruct() # destruct the queue\ncq = CappedQueue(\"fastrq_capped_queue\", 3)\ncq.push(1)\ncq.push(2)\ncq.push([3, 4]) # got \"err_qof\"\ncq.push(3)\ncq.push(4) # got \"err_qf\"\nof_cq = OfCappedQueue(\"fastrq_of_capped_queue\", 3)\nof_cq.push(1)\nof_cq.push([2, 3, 4])  # \"1\" would be forced out\n\n\n# deque\ndq = Deque(\"fastrq_deque\")\ndq.push_front([1, 2])\ndq.push_back([3, 4])\ndq.pop_front()\ndq.pop_back()\ndq.push_front_ni(3)\ndq.push_back_ni(5)\n\n# priority queue\npq = PriorityQueue(\"fastrq_priority_queue\")\npq.push({'alibaba': 1})\npq.push({'google': 0, 'microsoft': 2})\npq.indexof_one('google'); # got 0\npq.indexof_one('alibaba'); # got 1\npq.indexof_one('baidu'); # got None\npq.pop()\npq.pop(2)\npq.push_ni('ibm', 4)\npq.push_ni('amazon', 5)\n\n# stack\ns = Stack(\"fastrq_stack\")\ns.push([1,2,3])\ns.indexof_one(1); # got 2\ns.indexof_one(2); # got 1\ns.indexof_one(3); # got 0\ns.pop()\ns.push_ni(4)\n\n```\n\n## Data types\n\n### Queue\n\n+ first in and first out\n+ unlimited capacity\n+ support batch push and batch pop\n\n### Deque\n\nDerive from queue with more features\n\n+ support push front and push back\n+ support pop front and pop back\n\n### Capped Queue/Deque\n\nDerive from queue/deque with more features\n\n+ Have fixed capacity\n+ Push to a full one would fail\n+ Push to one whose positions are not enough would fail\n\n### Overflow-able Capped Queue/Deque\n\nDerive from capped queue/deque with more features\n\n+ The queue length would never exceed its capacity\n+ Push to an end would force out from the other end if one is full\n\n### Stack\n\n+ Last in and First out\n+ Unlimited capacity\n+ Support batch push and batch pop\n\n### Capped Stack\n\nDerive from Stack with more features\n\n+ Have fixed capacity\n+ Push to a full capped stack would fail\n+ Push to a capped stack whose positions are not enough would fail\n\n### Priority Queue\n\n+ The lower the score, the higher the priority\n+ Unlimited capacity\n+ Support batch push and batch pop\n\n### Capped Priority Queue\n\nDerive from Priority Queue with more features\n\n+ Have fixed capacity\n+ Push to a full one would fail\n+ Push to a capped one whose positions are not enough would fail\n\n### Overflow-able Capped Priority Queue\n\nDerive from Capped Priority Queue with more features\n\n+ The queue length would never exceed its capacity\n+ Push to would force out the lowest priority if queue is full\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimen%2Ffastrq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flimen%2Ffastrq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimen%2Ffastrq/lists"}