Registry / database / kth-node-redis

kth-node-redis

JSON →
library4.1.1jsnpmunverified

kth-node-redis is a Redis client module for Node.js (v4.1.1) that supports multiple named client instances. Released under the KTH organization on npm, it wraps the popular redis package (v5) and provides a simplified async API for creating and managing connections. Key differentiators include the ability to maintain multiple clients differentiated by a name parameter, automatic reuse and reconnection of clients with the same name, and compatibility with both native redis@5 configuration and the unpackRedisConfig from kth-node-configuration. This package is actively maintained with a semver release cadence, writing in TypeScript with built-in type declarations. Compared to using raw redis, it offers a higher-level abstraction for multi-client scenarios typical in microservices architectures.

npm install kth-node-redis
INSTALL
IMPORT
SIG · KTH-NODE-REDIS
K
kth-node-redis
databasejavascriptv4.1.1
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.

getClient
import { getClient } from 'kth-node-redis'
const { getClient } = require('kth-node-redis')
Package is ESM-default; named import works for both ESM and CJS via bundlers. CJS require works but is not recommended.
createClient
import { createClient } from 'kth-node-redis'
import createClient from 'kth-node-redis'
createClient is a named export, not default. Do not use default import, which would return undefined.
(default import)
import redis from 'kth-node-redis'
import { default as redis } from 'kth-node-redis'
Default import is an object containing getClient and createClient. Only use if you prefer namespace import.

Shows basic usage: create a named client, set and get a key, then destroy the client.

import { getClient } from 'kth-node-redis' async function run() { try { const client = await getClient('default', { url: process.env.REDIS_URL ?? 'redis://localhost:6379' }) await client.set('mykey', 'Hello World') const value = await client.get('mykey') console.log('Value:', value) client.destroy() } catch (err) { console.error('Error:', err) } } run()
Debug
Known issues
breakingMigrating from v3 to v4 removes all callback-based methods. Promise-based methods have new names (e.g., getAsync is now just get).
fix
Replace callback-style calls with async/await or promise .then(). For example, change client.get('key', cb) to await client.get('key').
affects: >=4.0.0
breakingIf used with @kth/api-call, ensure @kth/api-call is at least version 4.4.0 for compatibility.
fix
Update @kth/api-call to ^4.4.0 or later in your package.json.
affects: >=4.0.0
deprecatedThe option 'name' in getClient is optional and defaults to 'default'. In a future major version, passing no name may throw an error.
fix
Always provide a name argument to getClient to avoid future breakage.
affects: >=4.0.0
gotchaCalling getClient with the same name after a disconnection will return a new client (auto-reconnect), but the old client may still be referencing destroyed connections.
fix
Ensure you always use the latest client from a getClient promise and avoid storing old client references.
affects: >=0.0.0
Errors
Common errors & fixes
Error: The client is closed
Attempting to use a client instance after calling client.destroy() or after the underlying connection has been terminated.
fix
Do not reuse a client after destroy(). Obtain a fresh client via getClient().
TypeError: redis.getClient is not a function
Using a default import where a named import is expected, e.g., import redis from 'kth-node-redis' then redis.getClient().
fix
Use named import: import { getClient } from 'kth-node-redis'
TypeError: Cannot read properties of undefined (reading 'get')
Using default import destructively or importing non-existent symbol.
fix
Check import statement: should be import { getClient } from 'kth-node-redis'
Upgrade
Version history
4.1.1latest on npm
Audit
Dependencies
redisrequiredThe underlying Redis client library; kth-node-redis is a wrapper around redis@5.
Agent activity
2 hits · last 30 days
node
2
Resources
kth-node-redis — npm install kth-node-redis · libregistry