# redis-clustering-client

> A client for communicating with a Redis Cluster via the cluster's Sentinel applications.

Latest version **0.1.0** (published 2014-06-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install redis-clustering-client
pnpm add redis-clustering-client
yarn add redis-clustering-client
bun add redis-clustering-client
```

## 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.1.0 |
| Published | 2014-06-12 |
| First published | 2014-06-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jason Ogasian |
| Maintainers | jasonogasian |
| Keywords | redis, sentinel, cluster, client |

## Links

- npm: https://www.npmjs.com/package/redis-clustering-client
- Repository: https://github.com/jasonogasian/redis-clustering-client
- Issues: https://github.com/jasonogasian/redis-clustering-client/issues
- npm.io page: https://npm.io/package/redis-clustering-client

## Dependencies (1)

- [redis](https://npm.io/package/redis.md) ~0.10.3

## 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.1.0 (latest) — 2014-06-12
- 0.0.3 — 2014-06-10
- 0.0.2 — 2014-06-06
- 0.0.1 — 2014-06-02
- 0.0.0 — 2014-06-02

## README

redis-clustering-client
=======================

A client for communicating with a Redis Cluster via the cluster's Sentinel 
applications.

This module abstracts away the concept of a cluster to allow users to connect to 
the cluster master regardless of any failovers that have occurred since the last 
connection.  
You also have the option of connecting to a random slave of the cluster as well.  


Usage:
------

A simple example:

```js
  var Sentinel = require('./redis-sentinel.js');

  // Initialize to use all known Sentinels
  Sentinel.init('mymaster', 
  [
    { host:'localhost', port:26379},
    { host:'192.168.1.1', port:26379},
    { host:'anotherHost', port:26380}
  ], ready);


  function ready(err) {
    if (err) {
      console.log('ERROR: ' + err);
      return;
    }

    // Connect to the cluster master and set a value
    Sentinel.command('set', ['clustering', 'is cool!']);

    // Connect to a random slave and get a hash value
    Sentinel.command('hget', ['fuster', 'cluck'], function(err, resp) {
      if (err) {
        console.log('ERROR: ' + err);
        return;
      }
      console.log(resp);
    }, true);
  }
```  


API:
----

###cluster.init(cluster, sentinelArray, [callback])
Provide an ordered array of sentinels to use for connections. A connection to 
the reported Master Redis server is also established as a check.

* `cluster`: the name of the Redis Cluster in sentinel.conf (default: mymaster)
* `sentinelArray`: an array of objects describing each Redis Sentinel to attempt 
a connection with.  
*Example (default):* 
```js
    [{host:"localhost", port:26379}]
```
* `callback([err])`: called when test connection to master is completed or an error 
occurs

###cluster.command(cmd, args, [callback, slave])
Send a Redis command to the cluster master (or slave if `slave == true`) and 
receive the response.

* `cmd`: redis command to execute
* `args`: array of arguments to the command
* `callback(err, [res])`: response from the redis server
* `slave`: boolean - if true send command to a random slave


Defaults:
---------

* `cluster`: *mymaster*
* `sentinels`:
```js
    [{host:"localhost", port:26389}]
```

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