Registry / database / redis-abstraction

redis-abstraction

JSON →
library2.0.13jsnpmunverified

A Redis client pool abstraction (v2.0.13, 2024) that manages connections in a pool, supporting both single-node and cluster Redis deployments. Built on top of ioredis, it provides acquire/release semantics for cases where multiple connections are beneficial (blocking commands, pub/sub, large payloads). Provides typescript types and exposes a unified interface (IORedisClientPool) with methods for commands, pipelines, and Lua scripts. Currently only supports ioredis, with no plans for other backends. Release cadence is low, with no recent updates. Key differentiator: offers connection pooling over a single-threaded Redis client, which is uncommon.

npm install redis-abstraction
INSTALL
IMPORT
SIG · REDIS-ABSTRACTION
R
redis-abstraction
databasejavascriptv2.0.13
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.

IORedisClientPool
import { IORedisClientPool } from 'redis-abstraction'
const IORedisClientPool = require('redis-abstraction').IORedisClientPool
Both ESM and CJS imports work; package ships TypeScript types.
IRedisClientPool
import type { IRedisClientPool } from 'redis-abstraction'
import { IRedisClientPool } from 'redis-abstraction' (if used as value)
IRedisClientPool is a TypeScript interface, not a runtime value.

Initializes a single-node Redis pool, acquires a connection, runs SET and GET commands, then releases the connection.

import { IORedisClientPool } from 'redis-abstraction'; import Redis from 'ioredis'; import { Cluster } from 'ioredis'; function parseRedisConnectionString(connectionString: string) { return { host: 'localhost', port: 6379, password: '' }; } const connectionString = 'redis://localhost:6379'; const connectionInjector = () => IORedisClientPool.IORedisClientClusterFactory( [connectionString], Redis, Cluster, parseRedisConnectionString ); const pool = new IORedisClientPool(connectionInjector); async function main() { const token = pool.generateUniqueToken('demo'); await pool.acquire(token); const result = await pool.run(token, ['SET', 'foo', 'bar']); console.log('SET result:', result); const value = await pool.run(token, ['GET', 'foo']); console.log('GET result:', value); await pool.release(token); } main().then(() => process.exit(0));
Debug
Known issues
gotchaThe pool does not automatically retry failed commands; errors are thrown directly.
fix
Wrap pool.run() in try/catch or use ioredis retry strategy in the connection factory.
affects: >=2.0.0
gotchaConnections must be acquired before running commands, and released after use. Forgetting release will leak connections.
fix
Always use try/finally or use a wrapper that manages acquire/release automatically.
affects: >=1.0.0
deprecatedThe package only supports ioredis; future versions may support other Redis libraries but no timeline is given.
fix
If you need a different Redis client (e.g., node-redis), consider using it directly.
affects: >=2.0.0
Errors
Common errors & fixes
Error: connect ECONNREFUSED 127.0.0.1:6379
No Redis server running at the configured host/port.
fix
Start Redis locally (docker run --name test-redis -p 6379:6379 -d redis:latest) or update connection string.
TypeError: pool.run is not a function
Pool not initialized correctly or wrong import.
fix
Ensure you instantiate IORedisClientPool with a connectionInjector and use the returned instance.
Upgrade
Version history
2.0.13latest on npm
Audit
Dependencies
ioredisrequiredUnderlying Redis client library used by the pool for all connections.
Agent activity
9 hits · last 30 days
node
8
Resources
redis-abstraction — npm install redis-abstraction · libregistry