Registry / database / runsv-redis

runsv-redis

JSON →
library3.0.4jsnpmunverified

Service wrapper for node-redis v4+ within the runsv lifecycle management system. Version 3.0.4, released as part of the runsv ecosystem for Node.js >=18. It integrates Redis client lifecycle with runsv's service orchestration, automatically starting/stopping connections. Ships TypeScript types. Differentiator: handles client creation, reconnection, and shutdown via runsv hooks, reducing boilerplate for Redis-dependent services.

npm install runsv-redis
INSTALL
IMPORT
SIG · RUNSV-REDIS
R
runsv-redis
databasejavascriptv3.0.4
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.

create
import { create } from 'runsv-redis'
import { createService } from 'runsv-redis'
only named export 'create' available
default
import runsvRedis from 'runsv-redis'
const runsvRedis = require('runsv-redis')
ESM-only, s no default export export default binding exists (it is not a named export); actually there's no default export—only named 'create'; this line is wrong, but included as a common mistake
type imports
import type { RunSVRedisOptions } from 'runsv-redis'
import { createOptions } from 'runsv-redis'
types exported for options, but naming may differ; check actual exports

Create a Redis service with runsv, start the lifecycle, and perform basic set/get operations.

import redis from 'redis'; import * as runsv from 'runsv'; import { create } from 'runsv-redis'; const nodeRedisOptions = { url: process.env.REDIS_URL ?? 'redis://localhost:6379' }; const redisService = create(redis, nodeRedisOptions); runsv.addService(redisService); await runsv.start(); const client = runsv.getClients().redis; await client.set('key', 'value'); const val = await client.get('key'); console.log(val); // 'value' await runsv.stop();
Debug
Known issues
breakingrunsv-redis v3 requires runs v3 and node-redis v4+. Using older runsv or node-redis versions will cause runtime errors.
fix
Update runsv to ^3.0.0 and node-redis to ^4.0.0
affects: >=3.0.0
deprecatedrunsv-redis v2 used a different API: createService instead of create.
fix
Use create from runsv-redis v3; see migration guide
affects: >=2.0.0 <3.0.0
gotchaThe first argument to create() is the redis module (the library itself), not a client instance. Passing a client will fail.
fix
Pass the redis module: import redis from 'redis'; create(redis, options)
affects: >=3.0.0
gotchagetClients() returns an object keyed by service name; service name defaults to 'redis' but can be customized in options. Accessing wrong key yields undefined.
fix
Verify service name: runsv.getClients().redis or use the set name
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'runsv-redis'
Package not installed or version mismatch
fix
npm install runsv-redis@latest
TypeError: client.hmset is not a function
Using node-redis v4 which replaced hmset with hSet
fix
Use client.hSet('key', { field: 'value' }) instead of client.hmset(['key', 'field', 'value'])
Error: The first argument must be the redis module
Passed a client instance instead of the redis module
fix
import redis from 'redis'; create(redis, options)
Upgrade
Version history
3.0.4latest on npm
Audit
Dependencies
node-redisrequiredpeer dependency — the underlying Redis client library, version ^4.0.0
Agent activity
18 hits · last 30 days
node
14
Meta
2
Resources
runsv-redis — npm install runsv-redis · libregistry