A global Redis connection manager for Node.js that reuses a single connection (or pair for Pub/Sub) across modules. Current stable version is 5.4.0. Released with moderate cadence. Differentiators: automatically manages connection lifecycle, supports both standard and subscriber connections, and simplifies test cleanup by allowing a single close call. Provides a singleton pattern to avoid exhausting Redis connection limits.
npm install redis-connectionNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a global Redis connection, performing basic set/get, and closing the connection.
Switch to 'redis' v4 client: import { createClient } from 'redis'; const client = createClient(); await client.connect();Use redis.duplicate() with client.duplicate() to create a subscriber connection.
Use dynamic import() if needed, but prefer CommonJS require() or switch to a modern Redis client library.
Understand that it's a singleton. If you need multiple connections, manage them manually with 'redis' directly.
Use CommonJS: const redisClient = require('redis-connection')(); then call the function.Start Redis server: redis-server, or configure REDIS_URL environment variable pointing to your Redis instance.
Upgrade your project to use 'redis' v4 directly. Replace require('redis-connection') with import { createClient } from 'redis'.