# redis-cluster-client

> Automatic Redis Failover

Latest version **1.0.1** (published 2013-10-31) · BSD-3-Clause license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2013-10-31 |
| First published | 2013-10-30 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | 李斌 |
| Maintainers | piaolingxue |
| Keywords | redis, failover, cluster, ha |

## Links

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

## Dependencies (6)

- [async](https://npm.io/package/async.md) ~0.1.22
- [redis](https://npm.io/package/redis.md) ~0.7.1
- [hashring](https://npm.io/package/hashring.md) ~1.0.2
- [zookeeper](https://npm.io/package/zookeeper.md) ~3.4.5-2
- [underscore](https://npm.io/package/underscore.md) ~1.3.1
- [generic-pool](https://npm.io/package/generic-pool.md) ~2.0.4

## 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.1 (latest) — 2013-10-31
- 1.0.0 — 2013-10-30

## README

# redis-failover-in-nodejs

Automatic Redis Failover

[![build status](https://secure.travis-ci.org/piaolingxue/redis-cluster-client.png)](http://travis-ci.org/piaolingxue/redis-cluster-client)

## Installation

This module is installed via npm:

``` bash
$ npm install redis-failover-node
```

## Example Usage

``` js
var expect = require('expect.js'),
    ClusterClient = require('redis-cluster-client');

describe('testcase for cluster client', function() {
    it('client for', function(done) {
        this.timeout(100000000);
        var options = {zkservers:'localhost:6388,localhost:2181'};
        var client = new ClusterClient(options);
        client.init();
        client.on('error', function(err) {
            console.error('err:%s', err);
            done();
        });

        client.on('connect', function(client) {
            var count = 0;
            function batch() {
                setTimeout(function() {
                    client.clientFor(count, function(err, c) {
                        // console.log('%s:%d set %d %d', c.host, c.port, count, count);
                        c.set(count, count, function() {
                            count += 1;
                            if (count > 1000) {
                                console.log('exit.');
                                done();
                            }
                            console.log('count:%d', count);
                            c.release();
                            process.nextTick(batch);
                        });
                    });
                }, 1000);
            }
            batch();
        });
    });



    it.only('cluster command', function(done) {
        this.timeout(100000000);
        var options = {zkservers:'localhost:6388,localhost:2181'};
        var client = new ClusterClient(options);
        client.init();
        client.on('error', function(err) {
            console.error('err:%s', err);
            done();
        });
        client.on('connect', function(client) {
            var count = 0;
            function batch() {
                setTimeout(function() {
                    client.set(count, count, function() {
                            count += 1;
                            if (count > 1000) {
                                console.log('exit.');
                                done();
                            }
                            console.log('count:%d', count);
                            process.nextTick(batch);
                    });
                }, 1000);
            }
            batch();
        });
    });

    process.on("uncaughtException", function (error) {
        console.log('uncaught Exception:%j', error.stack);
    });

});
```

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