{"id":16352090,"url":"https://github.com/bugthesystem/ioredis-eventemitter","last_synced_at":"2025-10-26T02:31:29.683Z","repository":{"id":57133080,"uuid":"42882301","full_name":"bugthesystem/ioredis-eventemitter","owner":"bugthesystem","description":"Redis pubsub using an event emitter via ioredis Redis client for Node.js","archived":false,"fork":false,"pushed_at":"2015-09-22T13:51:02.000Z","size":145,"stargazers_count":11,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T13:49:50.351Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/bugthesystem.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":"2015-09-21T17:30:23.000Z","updated_at":"2022-08-10T15:37:52.000Z","dependencies_parsed_at":"2022-09-03T13:31:05.948Z","dependency_job_id":null,"html_url":"https://github.com/bugthesystem/ioredis-eventemitter","commit_stats":null,"previous_names":["ziyasal/ioredis-eventemitter"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugthesystem%2Fioredis-eventemitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugthesystem%2Fioredis-eventemitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugthesystem%2Fioredis-eventemitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugthesystem%2Fioredis-eventemitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bugthesystem","download_url":"https://codeload.github.com/bugthesystem/ioredis-eventemitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238247989,"owners_count":19440879,"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":[],"created_at":"2024-10-11T01:24:57.067Z","updated_at":"2025-10-26T02:31:29.368Z","avatar_url":"https://github.com/bugthesystem.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ioredis-eventemitter\nRedis pubsub using an event emitter via ioredis Redis client. \n\n[![NPM](https://nodei.co/npm/ioredis-eventemitter.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/ioredis-eventemitter/) [![npm version](https://badge.fury.io/js/ioredis-eventemitter.svg)](http://badge.fury.io/js/ioredis-eventemitter) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/ziyasal/ioredis-eventemitter/master/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/ziyasal/ioredis-eventemitter.svg)](https://github.com/ziyasal/ioredis-eventemitter/issues)  \n[ioredis](https://github.com/luin/ioredis) supports [Cluster](http://redis.io/topics/cluster-tutorial) and [Sentinel](http://redis.io/topics/sentinel)\n\n\u003e [ioredis](https://github.com/luin/ioredis) is a robust, performance-focused and full-featured Redis client for Node and io.js.  \n\n_This work based on [redis-eventemitter](https://github.com/freeall/redis-eventemitter)_\n\n##Install  \n```js\n\tnpm install ioredis-eventemitter\n```\n\n## Usage\n\n**pub/sub clients must be compatible [ioredis](https://github.com/luin/ioredis)**\n\n```js\nvar redis = require('ioredis-eventemitter');\n\nvar pubsub = redis({\n\tport: 6379,\n\thost: '127.0.0.1',\n\tprefix: 'production:',\n\tpassword: 'mypassword'\n\t// in case you want to control Redis clients\n\t// creation you can specify pub/sub clients pair:\n\t// pub: pubClient,\n\t// sub: subClient\n});\n\n// Listen for messages on the *:newuser channel\npubsub.on('*:newuser', function(channel, user) {\n\tconsole.log(channel); // prints \"myservice:newuser\"\n\tconsole.log(user);    // user is a json map as expected\n});\n\n// Publish an event \"production:myservice:newuser\" to the redis pubsub\npubsub.emit('myservice:newuser', { id:'a1b2c3', email:'foo@example.com' });\n```\n\n## API\n\n### .emit(channel, messages...) [publish]\n\n``` js\nvar redis = require('ioredis-eventemitter');\nvar pubsub = redis({ prefix: 'production:' });\n\npubsub.emit('myservice:newuser', { id:'a1b2c3' });\n```\n\n### .on(pattern, function(channel, messages...) { ... }) [subscribe]\n\n``` js\nvar redis = require('ioredis-eventemitter');\nvar pubsub = redis({ prefix:'production:' });\n\npubsub.on('*:newuser', function(channel, message) {\n\tconsole.log(channel); // myservice:newuser\n\tconsole.log(message); // { id:'a1b2c3' }\n});\n```\n\n### .on('error', function(err) { ... }) [error handling]\n\nTo be able to handle errors (like when the redis server is down) `.on('error', ...)` should be used.\n\nNote that this means that you can't listen for messages on the `error` channel.\n\n### .removeListener(pattern, listener)\n\nRemoves listener.\n\n### .removeAllListeners(pattern)\n\nRemoves all listeners.\n\n## Options\n\n### port\n\nPort for the redis server. Defaults to 6379.\n\n### host\n\nHost for the redis server. Defaults to 127.0.0.1.\n\n### password\n\nPassword for the redis server. Defaults to not being set.\n\n### prefix\n\nA prefix that is added to the channel name, when publishing events to the redis pubsub. Useful for separating services or environments, e.g. `production`, `development`, and `staging`.\n\nIt is also removed when the listeners is invoked.\n\n### pub\n\n[ioredis](https://github.com/luin/ioredis) compatible Redis client instance used for `publish`.\n\n### sub\n\n[ioredis](https://github.com/luin/ioredis) compatible Redis client instance used for `subscribe`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugthesystem%2Fioredis-eventemitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbugthesystem%2Fioredis-eventemitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugthesystem%2Fioredis-eventemitter/lists"}