{"id":24106176,"url":"https://github.com/mikesparr/redis-priority-queue","last_synced_at":"2026-05-15T14:07:53.624Z","repository":{"id":57349785,"uuid":"132638250","full_name":"mikesparr/redis-priority-queue","owner":"mikesparr","description":"Simple Promise based multi-channel priority queue using Redis sorted set","archived":false,"fork":false,"pushed_at":"2019-04-09T23:00:19.000Z","size":107,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-21T19:02:31.658Z","etag":null,"topics":["priority-queue","promises","redis","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/mikesparr.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-08T16:48:15.000Z","updated_at":"2019-04-09T23:00:21.000Z","dependencies_parsed_at":"2022-09-15T15:30:53.609Z","dependency_job_id":null,"html_url":"https://github.com/mikesparr/redis-priority-queue","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesparr%2Fredis-priority-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesparr%2Fredis-priority-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesparr%2Fredis-priority-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesparr%2Fredis-priority-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikesparr","download_url":"https://codeload.github.com/mikesparr/redis-priority-queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241078927,"owners_count":19905960,"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":["priority-queue","promises","redis","typescript"],"created_at":"2025-01-10T21:18:08.091Z","updated_at":"2026-05-15T14:07:48.601Z","avatar_url":"https://github.com/mikesparr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redis Priority Queue\nThis is a simple Promise based multi-channel priority queue implementation that leverages Redis sorted set.\n\n# Requirements\nYou will need Redis server running.\n\n# Installation\n```bash\nnpm install redis-priority-queue\nyarn add redis-priority-queue\n```\n\n# Test\nThe test script in `package.json` preprocesses the `.ts` file and then executes.\n\n`npm test`\n\n# Usage\nThe source was written in Typescript, yet it compiles to Javascript (`npm run build`). You can use in ES5 or later supported environments. The following code snippets are implemented in the `__tests__` folder.\n\n## Quick start (Node)\n```javascript\nconst queue = require('redis-priority-queue');\n\nconst config = queue.RedisConfig(\"localhost\", 6379, null, null);\n\nconst myQueue = new queue.RedisPriorityQueue(config);\n\nmyQueue.length(\"emptyQueue\")\n  .then(result =\u003e {\n    console.log({result});\n  })\n  .catch(error =\u003e {\n    console.error({error});\n  });\n```\n\n## Optional with existing client\nIf you already have a program with a `RedisClient` you can pass the client as an optional second parameter.\n```javascript\nconst myQueue = new queue.RedisPriorityQueue(null, client);\n\nmyQueue.length(\"emptyQueue\")\n  .then(result =\u003e {\n    console.log({result});\n  })\n  .catch(error =\u003e {\n    console.error({error});\n  });\n```\n\n## Typescript\n### Initialization\n```typescript\nimport {RedisConfig, IPriorityQueue, RedisPriorityQueue} from 'redis-priority-queue';\n\nlet config: RedisConfig = new RedisConfig(\n    \"localhost\",\n    6379,\n    null,\n    null\n);\n\nlet myQueue : IPriorityQueue\u003cstring\u003e = new RedisPriorityQueue(config);\n```\n\n### Insert element\n```typescript\nPromise.all([\n    myQueue.insertWithPriority(testKey, \"hello\", 1),\n    myQueue.insertWithPriority(testKey, \"world\", 2),\n    myQueue.insertWithPriority(testKey, \"foo\", 1)\n])\n    .then(values =\u003e {\n        done();\n    })\n    .catch(error =\u003e {\n        done.fail(error);\n    });\n```\n\n### Pull highest score element\n```typescript\nmyQueue.pullHighestPriority(testKey)\n    .then(result =\u003e {\n        // assert popped value is highest priority\n        expect(result).toEqual(\"world\");\n    })\n    .catch(error =\u003e {\n        done.fail(error);\n    });\n```\n\n### Peek highest score element\n```typescript\nmyQueue.peek(testKey)\n    .then(result =\u003e {\n        expect(result).toEqual(\"world\");\n        done();\n    })\n    .catch(error =\u003e {\n        done.fail(error);\n    });\n```\n\n### Check if empty\n```typescript\nmyQueue.isEmpty(testKey)\n    .then(result =\u003e {\n        expect(result).toBeFalsy();\n        done();\n    })\n    .catch(error =\u003e {\n        done.fail(error);\n    });\n```\n\n### Get queue length\n```typescript\nmyQueue.length(testKey)\n    .then(result =\u003e {\n        expect(result).toEqual(3);\n        done();\n    })\n    .catch(error =\u003e {\n        done.fail(error);\n    });\n```\n\n# Contributing\nI haven't thought that far ahead yet. I needed this for my project and wanted to give back. ;-)\n\n# License\nMIT (if you enhance it, fork and PR so the community benefits)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikesparr%2Fredis-priority-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikesparr%2Fredis-priority-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikesparr%2Fredis-priority-queue/lists"}