Registry / storage / redis-kv-store

redis-kv-store

JSON →
library6.0.2jsnpmunverified

A simple Redis-based key/value store with an API identical to memory-kv-store, designed for Node.js >=24.14.0. Version 6.0.2 is current, ESM-only, and ships TypeScript types. It depends on a simple-redis-service instance for Redis connectivity. The library is lightweight, focused on minimal abstraction, and intended for use in Node.js server environments.

npm install redis-kv-store
INSTALL
IMPORT
SIG · REDIS-KV-STORE
R
redis-kv-store
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.

initRedisKV
✓ import initRedisKV from 'redis-kv-store'
✗ const initRedisKV = require('redis-kv-store')
ESM-only since v6; CommonJS require() will fail.
RedisKVService
✓ import type { RedisKVService } from 'redis-kv-store'
TypeScript type exported; use type import to avoid runtime issues.
initRedisKV
✓ const initRedisKV = (await import('redis-kv-store')).default
✗ const { initRedisKV } = require('redis-kv-store')
In ESM context, default export is initRedisKV; named destructuring from CJS is wrong.

Initializes a Redis service and creates a key-value store, sets and retrieves a value, then deletes it.

import initRedisService from 'simple-redis-service'; import initRedisKV from 'redis-kv-store'; const redis = await initRedisService({ REDIS: { host: process.env.REDIS_HOST ?? 'localhost', port: Number(process.env.REDIS_PORT ?? 6379), }, ENV: process.env, log: console.log.bind(console), }); const redisKV = await initRedisKV({ redis, log: console.log.bind(console), }); await redisKV.set('greeting', 'Hello, world!'); const value = await redisKV.get('greeting'); console.log(value); // 'Hello, world!' await redisKV.del('greeting'); const gone = await redisKV.get('greeting'); console.log(gone); // undefined
Debug
Known issues
breakingVersion 6.0.0+ dropped support for CommonJS (require()). Only ESM imports (import) are supported.
fix
Migrate to ESM by using 'import' syntax or dynamic import(). For Node.js, enable 'type': 'module' in package.json or use .mjs extension.
affects: >=6.0.0
breakingNode.js version requirement raised to >=24.14.0. Older Node versions will fail to load the module.
fix
Upgrade Node.js to version 24.14.0 or higher.
affects: >=6.0.0
gotchaThe library expects the redis service's log function to be passed explicitly; forgetting to provide it may cause runtime errors or silent failures.
fix
Always provide a valid log function, e.g., 'console.log.bind(console)' or a custom logger.
affects: >=1.0.0
gotchaThe 'redis' service injected must be a 'simple-redis-service' instance; using a raw ioredis or redis client will break because the API shape differs.
fix
Wrap your Redis client with 'simple-redis-service' before passing it to initRedisKV.
affects: >=1.0.0
deprecatedDeprecated in v5: the constructor-style usage was removed. Only the factory function initRedisKV is supported.
fix
Use initRedisKV() factory instead of 'new RedisKVStore()'.
affects: >=5.0.0 <6.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/redis-kv-store/index.js from /path/to/project/app.js not supported.
Using require() on an ESM-only module (v6+).
fix
Switch to import syntax or dynamic import(). If you must use require(), downgrade to v5 (not recommended).
TypeError: redisKV.get is not a function
initRedisKV was called without 'await' or the returned promise was not resolved.
fix
Use 'await initRedisKV({...})' or '.then()' to get the actual service instance.
TypeError: services.redis is not a function
The injected 'redis' object does not match the expected simple-redis-service interface.
fix
Ensure you pass a valid simple-redis-service instance, not a raw Redis client.
Upgrade
Version history
6.0.2latest on npm
Audit
Dependencies
simple-redis-servicerequiredRequired to provide a Redis client instance
Agent activity
24 hits · last 30 days
node
20
Meta
1
OpenAI (training)
1
Resources
redis-kv-store — npm install redis-kv-store · libregistry