Registry / storage / simple-redis-service

simple-redis-service

JSON →
library6.0.2jsnpmunverified

A lightweight Redis wrapper around the ioredis module, designed for mocking key-value stores in tests or local scripts. Version 6.0.2 requires Node.js >=24.14.0. Ships TypeScript types. It requires a `delay` service and uses dependency injection for configuration, making it suitable for service-oriented applications. Compared to raw ioredis, it provides an abstraction layer for easier mocking and consistent service patterns.

npm install simple-redis-service
INSTALL
IMPORT
SIG · SIMPLE-REDIS-SERVI
S
simple-redis-service
storagejavascriptv6.0.2
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.

initRedisService
import initRedisService from 'simple-redis-service'
import { initRedisService } from 'simple-redis-service'
Default export, named import will fail
RedisService
import type { RedisService } from 'simple-redis-service'
import { RedisService } from 'simple-redis-service'
Type import only; not a runtime value
commonjs require
const initRedisService = require('simple-redis-service')
const { initRedisService } = require('simple-redis-service')
Destructuring require will give undefined

Initializes the Redis service with configuration from environment variables, sets and gets a value, then closes the connection.

import initRedisService from 'simple-redis-service'; const redis = await initRedisService({ REDIS: { host: process.env.REDIS_HOST ?? 'localhost', port: parseInt(process.env.REDIS_PORT ?? '6379', 10), }, ENV: process.env, log: console.log.bind(console), }); await redis.set('foo', 'bar'); const value = await redis.get('foo'); console.log(value); // 'bar' await redis.close();
Debug
Known issues
breakingRequires Node.js >=24.14.0. Older versions will fail with syntax errors.
fix
Upgrade Node.js to v24.14.0 or later, or downgrade simple-redis-service to a version compatible with your Node.
affects: <6.0.0
breakingDefault export; named import { initRedisService } will yield undefined.
fix
Use default import: import initRedisService from 'simple-redis-service'
affects: >=6.0.0
deprecatedThe `REDIS_PASSWORD_ENV_NAME` service parameter is deprecated in favor of reading password directly from ENV.
fix
Set REDIS_PASSWORD_ENV_NAME in the services object, or migrate to v6 and pass password via ENV.
affects: >=5.0.0 <6.0.0
gotchaRequires a `delay` service to be passed in if using features that need delays (e.g., retries).
fix
Provide a delay function: usually from common-services or a simple setTimeout wrapper.
affects: >=0.1.0
gotchaThe `log` service must be a function (e.g., console.log). Passing an object with .log method may cause errors.
fix
Use console.log.bind(console) or a function with the same signature (message: string) => void.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: initRedisService is not a function
Using named import instead of default import
fix
import initRedisService from 'simple-redis-service' (not { initRedisService })
Error: Cannot find module 'ioredis'
Missing ioredis dependency
fix
npm install ioredis
TypeError: services.log is not a function
Passing an object with a log property (e.g., { log: console }) instead of a function
fix
Pass console.log.bind(console) or a function with signature (message: string) => void
Redis connection refused: Error: connect ECONNREFUSED 127.0.0.1:6379
Redis server not running or wrong host/port
fix
Ensure Redis is running, or set REDIS_HOST/REDIS_PORT environment variables to the correct values.
Upgrade
Version history
6.0.2latest on npm
Audit
Dependencies
ioredisrequiredUnderlying Redis client
common-servicesoptionalProvides the required delay service implementation
Agent activity
24 hits · last 30 days
node
24
Resources
simple-redis-service — npm install simple-redis-service · libregistry