# pool-redis-promise

> wrapper for pool-redis that provides a promise-based implementation

Latest version **1.0.1** (published 2015-07-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install pool-redis-promise
pnpm add pool-redis-promise
yarn add pool-redis-promise
bun add pool-redis-promise
```

## 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 | 2015-07-26 |
| First published | 2015-07-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Chris Hourihan |
| Maintainers | kristofmic |
| Keywords | node, redis, pool, promise |

## Links

- npm: https://www.npmjs.com/package/pool-redis-promise
- Repository: https://github.com/kristofmic/pool-redis-promise
- Homepage: https://github.com/kristofmic/pool-redis-promise#readme
- Issues: https://github.com/kristofmic/pool-redis-promise/issues
- npm.io page: https://npm.io/package/pool-redis-promise

## Dependencies (4)

- [colors](https://npm.io/package/colors.md) ^1.1.0
- [lodash](https://npm.io/package/lodash.md) ^3.10.0
- [bluebird](https://npm.io/package/bluebird.md) ^2.9.34
- [pool-redis](https://npm.io/package/pool-redis.md) ^0.1.2

## 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) — 2015-07-26
- 1.0.0 — 2015-07-26

## README

Pool-redis-promise
================

Pool-redis-promise provides a wrapper to the [pool-redis](https://github.com/Valzon/node-redis-pool) npm library.

## Usage

Pool-redis-promise wraps pool-redis, which wraps [node_redis](https://github.com/NodeRedis/node_redis), providing redis connection pooling with a clean promise-based API (based on [Bluebird](https://github.com/petkaantonov/bluebird));

Pool-redis-promise exposes a simple class that can be invoked with a [configuration](https://www.npmjs.com/package/pool-redis#redis-pool-options) that pool-redis expects, which is then passed to the redis clients. The instance returned exposes a single public API method `#getClientAsync`, which must be invoked with a single callback function argument which receives the redis client from the pool as its single argument.

All calls to `getClientAsync` returns a promise. The client itself is populated with both promise-based and non-promised based methods. The non-promise-based methods are those on the (standard redis client)[https://github.com/NodeRedis/node_redis#sending-commands]. The promise-based methods are those same commands appended with `Async` (e.g., the callback-based `set` has a promise-based method `setAsync`). The promise-based methods accept the same arguments however return a promise and do not accept a callback as the last command (errors will bubble to `catch` functions and successes will bubble to the next `then`);

### Default configuration

Pool-redis-promise sets up a default configuration when a new instance is created if a configuration is not provided (or only a partial configuration is provided). The default configuration is as follows:

```js
  {
    host: 'localhost',
    port: 6379,
    password: null,
    maxConnections: 50,
    handleRedisError: false,
    options: {
      database: 0,
      connect_timeout: 5000
    }
  }

```

## API

### #constructor

`new require('pool-redis-promise')([config])`

Initializes a new redis connection pool with the provided configuration settings. Any settings not provided will fallback to the defaults listed above.

**Arguments**

1. [configs] *(Object)*: *Optional* Configuration settings (see [pool-redis options](https://www.npmjs.com/package/pool-redis#redis-pool-options) for the settings that can be provided)

**Returns**

Instance of a redis connection pool

### #getClientAsync(callback)

Fetches a client from the redis connection pool and passes the client as the first and only argument to the callback function. As previously mentioned, the client contains callback-based and promise-based methods. The promise-based methods are the same as the standard redis client methods but with `Async` appended and return a promise instead of accepting a callback as the last argument.

**Arguments**

1. callback *(Function)*: Callback function that will receive a client from the redis connection pool

**Returns**

A Bluebird promise

## Testing

Tests can be run via `npm test`. Ensure that an instance of Redis is running for the integration tests.

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