Registry / database / ioredis-conn-pool

ioredis-conn-pool

JSON →
library2.0.1jsnpmunverified

ioredis-conn-pool is a Redis connection pool implementation based on ioredis and generic-pool, designed to simplify the management of Redis client connections in Node.js applications. Current stable version is 2.0.1. It uses generic-pool for robust connection lifecycle management with configurable min/max pool size, and relies on ioredis for Redis protocol handling. Compared to alternatives like redis-pool or simple ioredis client reuse, it provides a higher-level API that abstracts acquire/release patterns and supports TypeScript out of the box. Released under MIT license.

npm install ioredis-conn-pool
INSTALL
IMPORT
SIG · IOREDIS-CONN-POOL
I
ioredis-conn-pool
databasejavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RedisPool
import { RedisPool } from 'ioredis-conn-pool'
import RedisPool from 'ioredis-conn-pool'
Named export, not default. ESM and TypeScript both use named import.
RedisPoolOptions
import { RedisPoolOptions } from 'ioredis-conn-pool'
import type { RedisPoolOptions } from 'ioredis-conn-pool'
Type import is fine but not wrong; the library ships types so you can use either.
default
import RedisPool from 'ioredis-conn-pool'
There is no default export. Always use named import.

Shows how to create a RedisPool, acquire a connection, execute commands, release it, and close the pool.

import { RedisPool } from 'ioredis-conn-pool'; const pool = new RedisPool({ redis: { host: process.env.REDIS_HOST ?? '127.0.0.1', port: Number(process.env.REDIS_PORT ?? 6379), password: process.env.REDIS_PASSWORD ?? '' }, pool: { min: 2, max: 10 } }); async function todo() { let client; try { client = await pool.getConnection(); await client.set('test', 'redis test'); const result = await client.get('test'); console.log('Saved successfully', result); } catch (e) { console.error(e); } finally { if (client) { await pool.release(client); console.log('Released'); } } await pool.end(); console.log('Closed all connections'); } todo();
Debug
Known issues
gotchaAlways release the client back to the pool using pool.release(client) after use to avoid resource leaks.
fix
Use try...finally block to ensure release.
affects: >=1.0
gotchaDo not manually close the ioredis client; use pool.end() to drain and close all connections gracefully.
fix
Call pool.end() instead of client.disconnect().
affects: >=1.0
breakingThe pool configuration changed between v1 and v2: v2 uses 'pool' sub-object while v1 used flat options like 'min' and 'max'.
fix
Wrap min/max inside a pool: {} object.
affects: >=2.0
deprecatedCalling pool.end() without awaiting is deprecated; it returns a Promise since v2.
fix
Always await pool.end().
affects: >=2.0
Errors
Common errors & fixes
Error: Cannot find module 'ioredis-conn-pool'
Package not installed or import path typo.
fix
Run npm install ioredis-conn-pool and ensure the import path is correct: 'ioredis-conn-pool'.
TypeError: pool.getConnection is not a function
Using default import instead of named import.
fix
Use import { RedisPool } from 'ioredis-conn-pool'.
Error: Redis connection refused
Wrong host/port or Redis server not running.
fix
Check Redis configuration and ensure server is reachable.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
ioredisrequiredCore Redis client dependency for executing commands
generic-poolrequiredProvides connection pool logic (acquire, release, drain)
Agent activity
6 hits · last 30 days
node
6
Resources
ioredis-conn-pool — npm install ioredis-conn-pool · libregistry