# ocbesbn-redis-events

> Module simplifying access to the publish/subscribe system provided by Redis.

Latest version **1.0.6** (published 2017-10-18) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install ocbesbn-redis-events
pnpm add ocbesbn-redis-events
yarn add ocbesbn-redis-events
bun add ocbesbn-redis-events
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2017-10-18 |
| First published | 2017-04-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Christian Drengenberg |
| Maintainers | kwierchris |
| Keywords | Redis, Events, Publish, Subscribe |

## Links

- npm: https://www.npmjs.com/package/ocbesbn-redis-events
- Repository: https://github.com/OpusCapita/redis-events
- Homepage: https://github.com/OpusCapita/redis-events#readme
- Issues: https://github.com/OpusCapita/redis-events/issues
- npm.io page: https://npm.io/package/ocbesbn-redis-events

## Dependencies (5)

- [redis](https://npm.io/package/redis.md) ^2.8.0
- [extend](https://npm.io/package/extend.md) ^3.0.1
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.1
- [ocbesbn-config](https://npm.io/package/ocbesbn-config.md) ^2.2.11
- [ocbesbn-logger](https://npm.io/package/ocbesbn-logger.md) ^1.0.5

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2017-10-18
- 1.0.5 — 2017-07-31
- 1.0.4 — 2017-04-27
- 1.0.3 — 2017-04-21
- 1.0.2 — 2017-04-19
- 1.0.1 — 2017-04-19
- 1.0.0 — 2017-04-19

## README

# ocbesbn-redis-events
[![Coverage Status](https://coveralls.io/repos/github/OpusCapita/redis-events/badge.svg?branch=master&rand=2)](https://coveralls.io/github/OpusCapita/redis-events?branch=master&rand=1)
![Build status](https://circleci.com/gh/OpusCapita/redis-events.svg?style=shield&circle-token=33dde9a3e5bbe120832064948a3d073ba7a6ab15)

This module provides simplified access to the publish/subscribe system provided by Redis. It uses Consul in order to determine the required Redis server endpoint and further configurations. To have a look at the full API, please visit the related [wiki page](https://github.com/OpusCapita/redis-events/wiki).

### Minimum setup
First got to your local code directory and run:
```
npm install ocbesbn-redis-events
```
To go with the minimum setup, you need to have access to a running **Consul server** to get your endpoint configuration for Redis. In addition, a **Redis server** is required which has to be registered inside Consul. If Redis password **authentication** is required, Consul has to provide the configuration key **{{your-service-name}}/redis/password** where *{{your-service-name}}* is the least name of the directory your code runs in. If authentication is not used, you can set the **consul.redisPasswordKey** to null or false when creating a new instance of RedisEvents.

If all this is set up, go to you code and add the following lines:

```JS
const RedisEvents = require('ocbesbn-redis-events');

var events = new RedisEvents({ consul : { host : '{{your-consul-host}}' } });

// Subscribe to a channel by name.
events.subscribe('my-channel', console.log).then(() => events.emit('Hello, world!', 'my-channel'));
// - OR -
// Subscribe to a channel by pattern.
events.subscribe('my-channel.*', console.log).then(() => events.emit('Hello, world!', 'my-channel.sub-channel'));

// Close all Redis connections.
events.disposeAll();
```

### Default configuration

The default configuration object provides hints about what the module's standard behavior is like.

```JS
{
    serializer : JSON.stringify,
    parser : JSON.parse,
    defaultEmitChannel : null,
    consul : {
        host : 'consul',
        redisServiceName  : 'redis',
        redisPasswordKey : 'redis/password'
    },
    context : {
    }
}
```

---
_Source: https://npm.io/package/ocbesbn-redis-events · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
