# @o1s/redis-testbench

> Redis (single instance and cluster) test bench

Latest version **1.0.2** (published 2021-11-29) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @o1s/redis-testbench
pnpm add @o1s/redis-testbench
yarn add @o1s/redis-testbench
bun add @o1s/redis-testbench
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-11-29 |
| First published | 2021-11-29 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gonzalo Arana |
| Maintainers | garana |
| Keywords | redis, redis-cluster, testbench |

## Links

- npm: https://www.npmjs.com/package/@o1s/redis-testbench
- Repository: https://github.com/garana/redis-testbench
- Homepage: https://github.com/garana/redis-testbench#readme
- Issues: https://github.com/garana/redis-testbench/issues
- npm.io page: https://npm.io/package/@o1s/redis-testbench

## Dependencies (1)

- [ioredis](https://npm.io/package/ioredis.md) ^4.28.0

## 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.2 (latest) — 2021-11-29
- 1.0.1 — 2021-11-29
- 1.0.0 — 2021-11-29

## README

# Redis Test Bench

Provide means to spin up & connect to:
* a redis instance,
* a redis cluster, composed of 3 shards, with 1 replica each,
* a set of monitors, that logs:
  * (almost all) redis commands,
  * expiring entries.

Note that the `npm` package only adds a simple function to create
an `IORedis` client, for either standalone Redis instance or for
the Redis Cluster.

## Installation

To be able to connect to the redis instance or cluster:
`npm install @o1s/redis-testbench`

You can use the exported function `buildClient`, which will return
an IORedis client (for standalone Redis instance or for a Redis
Cluster).

To boot the services, clone this repo and read the title
`Redis and Redis Cluster services` below.

## Connectivity

### Connecting to Redis services

* The single redis service is available:
  * outside docker-compose: as `localhost:6379`
  * inside docker-compose: as `redis:6379`
* The redis-cluster services are available:
  * outside docker-compose: `localhost:6380` to `localhost:6385`
    (requires nat support if ioredis is used).
  * inside docker-compose: as `redis-node-0:6379` to `redis-node-5:6379`.

### API Provided
* `buildClient` returns the required redis client (either for a
  single Redis instance or for the Redis Cluster).
* `buildOptionsFromEnv` builds the required options from env vars.

## Redis and Redis Cluster services

Docker and Docker Compose services should be started
from a git clone of this repo, not from the `npm install`ed.

To start all redis and redis cluster services:
```
. .setup.sh
docker-compose up --build
```

To start the redis instance alone:
```
docker-compose up --build redis redis-monitor redis-watch-expirations
```

To start only the redis cluster (6 nodes: 3 primaries + 1 replica
each):
```
. .setup.sh
docker-compose up --build \
  redis-node-0 \
  redis-node-1 \
  redis-node-2 \
  redis-node-3 \
  redis-node-4 \
  redis-node-5 \
  redis-monitor-0 \
  redis-monitor-1 \
  redis-monitor-2 \
  redis-monitor-3 \
  redis-monitor-4 \
  redis-monitor-5 \
  redis-watch-expirations-0 \
  redis-watch-expirations-1 \
  redis-watch-expirations-2 \
  redis-watch-expirations-3 \
  redis-watch-expirations-4 \
  redis-watch-expirations-5
```
* `redis-node-*`: these are the actual redis services
* `redis-monitor-*`: these will list (almost all) redis commands
* `redis-watch-expirations-*`: these will list entry expirations.

To do a clean start state:
``` 
. .setup.sh
docker-compose down;
docker-compose rm -f \
  redis-node-0 \
  redis-node-1 \
  redis-node-2 \
  redis-node-3 \
  redis-node-4 \
  redis-node-5;
docker-compose up --build;
```

The commands above can be run with:
```
bash -i start.sh 
```

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