# redis-sentinel

> Redis sentinel client for nodejs

Latest version **0.3.3** (published 2015-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install redis-sentinel
pnpm add redis-sentinel
yarn add redis-sentinel
bun add redis-sentinel
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2015-06-16 |
| First published | 2013-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 75 |
| Author | Ortoo Technologies |
| Maintainers | jamessharp |
| Keywords | redis |

## Links

- npm: https://www.npmjs.com/package/redis-sentinel
- Repository: https://github.com/ortoo/node-redis-sentinel
- Issues: https://github.com/ortoo/node-redis-sentinel/issues
- npm.io page: https://npm.io/package/redis-sentinel

## Dependencies (2)

- [when](https://npm.io/package/when.md) ^3.5.1
- [redis](https://npm.io/package/redis.md) 0.12.x

## 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

- 0.3.3 (latest) — 2015-06-16
- 0.3.2 — 2015-03-26
- 0.3.1 — 2015-03-05
- 0.3.0 — 2014-12-09
- 0.2.0 — 2014-11-20
- 0.1.3 — 2014-10-29
- 0.1.2 — 2014-10-28
- 0.1.1 — 2014-09-01
- 0.1.0 — 2014-06-17
- 0.0.9 — 2014-05-28
- 0.0.8 — 2014-05-15
- 0.0.7 — 2014-05-13
- 0.0.6 — 2014-03-18
- 0.0.5 — 2013-05-17
- 0.0.4 — 2013-03-31
- … 3 more at https://npm.io/package/redis-sentinel/versions

## README

node-redis-sentinel
===================

Wrapper around [node_redis](https://github.com/mranney/node_redis) creating a client pointing at the master server which autoupdates when the master goes down.

```javascript
var sentinel = require('redis-sentinel');

// List the sentinel endpoints
var endpoints = [
    {host: '127.0.0.1', port: 26379},
    {host: '127.0.0.1', port: 26380}
];

var opts = {}; // Standard node_redis client options
var masterName = 'mymaster';

// masterName and opts are optional - masterName defaults to 'mymaster'
var redisClient = sentinel.createClient(endpoints, masterName, opts);

// redisClient is a normal redis client, except that if the master goes down
// it will keep checking the sentinels for a new master and then connect to that.
// No need to monitor for reconnects etc - everything handled transparently
// Anything that persists over the normal node_redis reconnect will persist here. 
// Anything that doesn't, won't.

// An equivalent way of doing the above (if you don't want to have to pass the endpoints around all the time) is
var Sentinel = sentinel.Sentinel(endpoints);
var masterClient = Sentinel.createClient(masterName, opts);
```

## Connection to slaves or the sentinel itself ##
You can get a connection to a slave (chosen at random) or the first available sentinel from the endpoints by passing in the `role` attribute in the options. E.g.

```javascript
// The master is the default case if no role is specified.
var masterClient = sentinel.createClient(endpoints, masterName, {role: 'master'}); 
var slaveClient = sentinel.createClient(endpoints, masterName, {role: 'slave'});
var sentinelClient = sentinel.createClient(endpoints, {role: 'sentinel'});
```

Where you should also transparently get a reconnection to a new slave/sentinel if the existing one goes down.

## TODO ##
* We could probably be cleverer with reconnects etc. and there may be issues with the error handling

## Licence ##
MIT

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