{"id":15592204,"url":"https://github.com/derhuerst/redis-stream","last_synced_at":"2025-04-15T05:28:19.739Z","repository":{"id":57107618,"uuid":"169781302","full_name":"derhuerst/redis-stream","owner":"derhuerst","description":"Redis 5 Streams as readable \u0026 writable Node streams. Plus a CLI.","archived":false,"fork":false,"pushed_at":"2022-09-27T18:10:52.000Z","size":25,"stargazers_count":7,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-25T00:30:23.765Z","etag":null,"topics":["cli","redis","stream"],"latest_commit_sha":null,"homepage":"https://github.com/derhuerst/redis-stream#redis-stream","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derhuerst.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":"2019-02-08T18:36:04.000Z","updated_at":"2022-09-27T18:10:57.000Z","dependencies_parsed_at":"2022-08-20T17:11:19.157Z","dependency_job_id":null,"html_url":"https://github.com/derhuerst/redis-stream","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/derhuerst%2Fredis-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fredis-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fredis-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fredis-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derhuerst","download_url":"https://codeload.github.com/derhuerst/redis-stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232925369,"owners_count":18597666,"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":["cli","redis","stream"],"created_at":"2024-10-02T23:58:24.829Z","updated_at":"2025-01-07T19:28:04.810Z","avatar_url":"https://github.com/derhuerst.png","language":"JavaScript","funding_links":["https://github.com/sponsors/derhuerst"],"categories":[],"sub_categories":[],"readme":"# redis-stream\n\n**[Redis 5 Streams](https://redis.io/topics/streams-intro) as [readable \u0026 writable Node streams](https://nodejs.org/api/stream.html).** Plus a command line interface.\n\n[![npm version](https://img.shields.io/npm/v/@derhuerst/redis-stream.svg)](https://www.npmjs.com/package/@derhuerst/redis-stream)\n[![build status](https://api.travis-ci.org/derhuerst/redis-stream.svg?branch=master)](https://travis-ci.org/derhuerst/redis-stream)\n[![Prosperity/Apache license](https://img.shields.io/static/v1?label=license\u0026message=Prosperity%2FApache\u0026color=0997E8)](#license)\n![minimum Node.js version](https://img.shields.io/node/v/@derhuerst/redis-stream.svg)\n[![chat with me on Gitter](https://img.shields.io/badge/chat%20with%20me-on%20gitter-512e92.svg)](https://gitter.im/derhuerst)\n[![support me via GitHub Sponsors](https://img.shields.io/badge/support%20me-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)\n\n\n## Installation\n\n```shell\nnpm install @derhuerst/redis-stream\n```\n\n\n## Command line usage\n\n```\nUsage:\n    write-into-redis-stream \u003cstream-name\u003e\nExamples:\n    echo '{\"user\": \"jane\", \"text\": \"hey!\"}' | write-into-redis-stream chat-msgs\n```\n\n```\nUsage:\n    read-from-redis-stream \u003cstream-name\u003e [--history] [--live [--waitTimoout \u003cms\u003e]] [--limit \u003cn\u003e]\nOptions:\n\t--live             Wait for newly added items? Default: true\n\t--waitTimeout  -t  How long to wait for newly added items. Default: Infinity\n\t--history          Read all past items from the stream? Default: false\n\t--limit        -l  Maximum number of items to read. Default: Infinity\nExamples:\n    read-from-redis-stream chat-msgs --live --limit 1000\n```\n\n\n## Usage with JavaScript\n\n### Writing to a Redis Stream\n\n```js\nconst {createClient} = require('redis')\nconst createWriter = require('@derhuerst/redis-stream/writer')\n\nconst redis = createClient()\nconst writer = createWriter(redis, 'some-stream-name')\nwriter.once('finish', () =\u003e redis.quit())\nwriter.on('error', console.error)\n\nwriter.write({foo: 'bar'})\nwriter.end({hey: 'there!'})\n```\n\n### Reading from a Redis Stream\n\n```js\nconst {createClient} = require('redis')\nconst createReader = require('@derhuerst/redis-stream/reader')\n\nconst redis = createClient()\nconst reader = createReader(redis, 'some-stream-name')\nreader.on('data', console.log)\nreader.on('error', console.error)\n```\n\n\n## API\n\n### `createWriter(redis, streamName)`\n\nReturns a [readable stream](https://nodejs.org/api/stream.html#stream_writable_streams) in [object mode](https://nodejs.org/api/stream.html#stream_object_mode).\n\n### `createReader(redis, streamName, opt = {})`\n\nReturns a [readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) in [object mode](https://nodejs.org/api/stream.html#stream_object_mode). `opt` may be an object with the following entries:\n\n- `live`: Wait for newly added items? Default: `true`\n- `waitTimeout`: How long to wait for newly added items. Default: `Infinity`\n- `history`: Read all past items from the stream? Default: `false`\n- `limit`: Maximum number of items to read. Default: `Infinity`\n\n\n## License\n\nThis project is dual-licensed: **My contributions are licensed under the [*Prosperity Public License*](https://prosperitylicense.com), [contributions of other people](https://github.com/derhuerst/redis-stream/graphs/contributors) are licensed as [Apache 2.0](https://apache.org/licenses/LICENSE-2.0)**.\n\n\u003e This license allows you to use and share this software for noncommercial purposes for free and to try this software for commercial purposes for thirty days.\n\n\u003e Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, doesn’t count as use for a commercial purpose.\n\n[Get in touch with me](https://jannisr.de/) to buy a commercial license or read more about [why I sell private licenses for my projects](https://gist.github.com/derhuerst/0ef31ee82b6300d2cafd03d10dd522f7).\n\n\n## Contributing\n\nIf you have a question or need support using `redis-stream`, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to [the issues page](https://github.com/derhuerst/redis-stream/issues).\n\nBy contributing, you agree to release your modifications under the [Apache 2.0 license](LICENSE-APACHE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderhuerst%2Fredis-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderhuerst%2Fredis-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderhuerst%2Fredis-stream/lists"}