Registry / storage / redis-cache

redis-cache

JSON →
library0.2.1jsnpmunverified

A simple short-term caching module for Redis that stores and retrieves data by keys. At version 0.2.1, it provides basic set, get, and delete operations with TTL support. Differentiates from other Redis caching libraries by its minimalistic design and simplicity, but lacks advanced features like caching strategies or invalidation patterns. The library is relatively inactive with limited updates and community support, making it suitable only for very basic caching needs.

npm install redis-cache
INSTALL
IMPORT
SIG · REDIS-CACHE
R
redis-cache
storagejavascriptv0.2.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.

default
import redisCache from 'redis-cache'
const redisCache = require('redis-cache')
Package uses CommonJS and can be required; import syntax with default works in ESM environments.
set
import { set } from 'redis-cache'
const set = require('redis-cache').set
Named export available but not documented; prefer default import with method calls.
get
import { get } from 'redis-cache'
const get = require('redis-cache').get
Named export for get; default import also exposes get as method.
delete
import { delete } from 'redis-cache'
const del = require('redis-cache').del
Method named 'delete' in exports, but common mistake to look for 'del'.

Shows basic usage: create a Redis client, initialize the cache with a TTL of 60 seconds, then set, get, and delete a key.

import redis from 'redis'; import redisCache from 'redis-cache'; const client = redis.createClient(process.env.REDIS_URL ?? 'redis://localhost:6379'); const cache = redisCache(client, { ttl: 60 }); async function main() { await cache.set('key', 'value'); const val = await cache.get('key'); console.log('Cached value:', val); await cache.delete('key'); client.quit(); } main().catch(console.error);
Debug
Known issues
deprecatedPackage is no longer actively maintained; last update was years ago.
fix
Consider migrating to a maintained alternative like 'node-cache' or 'ioredis' with caching logic.
affects: >=0.0.0
breakingRequires a Redis client instance; does not manage connection lifecycle.
fix
Ensure you handle Redis client connection and error events yourself.
affects: >=0.0.0
gotchaThe library uses callbacks internally; async/await wrappers are not built-in.
fix
Wrap calls in Promises or use a promisify utility.
affects: <=0.2.1
gotchaTTL is set globally per cache instance; cannot set per key TTL.
fix
If per-key TTL needed, use a different library.
affects: <=0.2.1
Errors
Common errors & fixes
TypeError: redisCache is not a function
Default import may not work in some environments; requires CommonJS require.
fix
Use const redisCache = require('redis-cache').default or switch to require().
Error: Redis connection refused
Redis server is not running or URL is incorrect.
fix
Start Redis server or check REDIS_URL environment variable.
TypeError: cache.get is not a function
Cache object not properly initialized; client parameter missing.
fix
Ensure redisCache is called with a valid Redis client: redisCache(redisClient, options).
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
redisrequiredRequired to establish connection and interact with Redis server.
Agent activity
34 hits · last 30 days
node
31
OpenAI (training)
1
Resources