Registry / storage / node-cache-redis

node-cache-redis

JSON →
library6.4.2jsnpmunverified

Simplistic Node.js Redis caching module with generic-pool support for scalable, multithreaded environments. Version 6.4.2 provides a straightforward API (init, set, get) with connection pooling, configurable TTL, custom logging, and statistics. Requires Redis 4+ and Node.js 8+. Features UNLINK-based deletion and pattern deletion via redis.replicate_commands().

npm install node-cache-redis
INSTALL
IMPORT
SIG · NODE-CACHE-REDIS
N
node-cache-redis
storagejavascriptv6.4.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.

init
import { init } from 'node-cache-redis'
const init = require('node-cache-redis').init
ESM or CJS are both supported; require destructuring is fine but import is preferred.
set
import { set } from 'node-cache-redis'
const { set } = require('node-cache-redis').set
Import directly from named export; do not nest require calls.
get
import { get } from 'node-cache-redis'
const get = require('node-cache-redis').get
Named export, not default.
del
import { del } from 'node-cache-redis'
const del = require('node-cache-redis').delete
Use 'del', not 'delete'.

Initializes the cache, sets a value, retrieves it, and deletes it using async/await.

import { init, set, get, del } from 'node-cache-redis'; async function example() { init({ redisOptions: { host: 'localhost', port: 6379 }, ttlInSeconds: 3600 }); await set('user:1', { name: 'Alice', age: 30 }); const user = await get('user:1'); console.log('Cached user:', user); await del('user:1'); const deleted = await get('user:1'); console.log('After delete:', deleted); // null } example().catch(console.error);
Debug
Known issues
breakingVersion 4.0.0 introduced breaking changes; check CHANGELOG for details.
fix
Review migration guide for v4.0.0 at https://github.com/pasupulaphani/node-cache-redis/releases/tag/v4.0.0
affects: >=4.0.0
gotchaRequires Redis 4+; older versions will not work due to UNLINK and replicate_commands usage.
fix
Upgrade Redis server to version 4 or later.
affects: >=4.0.0
gotchainit() must be called before any cache operations, otherwise set/get will fail.
fix
Call init() at the start of your application.
affects: all
gotchaDefault TTL is not set; values persist indefinitely unless ttlInSeconds is provided.
fix
Pass ttlInSeconds option to init() to avoid memory leaks.
affects: all
Errors
Common errors & fixes
Error: Callback is not a function
Using async functions without await or callbacks incorrectly.
fix
Wrap set/get/del in async function and use await.
Redis connection refused
Redis server is not running or host/port is incorrect.
fix
Ensure Redis is started on localhost:6379 or provide correct redisOptions.
TypeError: Cannot read properties of undefined (reading 'set')
Calling set() without initializing the cache.
fix
Call init() before any cache operations.
Upgrade
Version history
6.4.2latest on npm
Audit
Dependencies
redisrequiredPeer dependency for Redis client functionality; version 4 or higher required.
generic-poolrequiredUsed for connection pooling support.
Agent activity
29 hits · last 30 days
node
28
Amazon
1
Resources
node-cache-redis — npm install node-cache-redis · libregistry