Registry / database / exp-rediscache

exp-rediscache

JSON →
library5.1.0jsnpmunverified

A Redis caching library (v5.1.0) designed to integrate with exp-asynccache. It provides a simple interface for caching values in Redis with optional TTL via SETEX, supports key namespacing, and configures the underlying Redis client's offline queue behavior. Stable release, actively maintained, no major updates in recent months. Differentiator: lightweight, relies on exp-asynccache for async caching patterns, minimal setup.

npm install exp-rediscache
INSTALL
IMPORT
SIG · EXP-REDISCACHE
E
exp-rediscache
databasejavascriptv5.1.0
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.

RedisCache
import { RedisCache } from 'exp-rediscache'
const RedisCache = require('exp-rediscache').RedisCache
ESM only. Default export is not available.
RedisCache (default import)
import RedisCache from 'exp-rediscache'
const RedisCache = require('exp-rediscache')
There is no default export. Must use named import.
RedisCacheOptions
import { RedisCache } from 'exp-rediscache'; // options are passed as constructor argument (no separate type export)
Options are typed inline; no separate export of options interface.

Initializes a RedisCache with custom host, port, offline queue disabled, and key prefix; shows lookup with TTL.

import { RedisCache } from 'exp-rediscache'; import { AsyncCache } from 'exp-asynccache'; const cache = new AsyncCache(new RedisCache({ host: process.env.REDIS_HOST ?? 'localhost', port: parseInt(process.env.REDIS_PORT ?? '6379', 10), enableOfflineQueue: false, keyPrefix: 'myapp' })); cache.lookup('key', (resolve) => { resolve(null, 'value', 60); // cache for 60 seconds }).then(value => { console.log(value); }).catch(err => { console.error(err); });
Debug
Known issues
gotchaThe underlying redis client (v2.x) queues commands when offline by default. This can cause unexpected delays and memory buildup if Redis is down.
fix
Set `enableOfflineQueue: false` in RedisCache options to fail fast.
affects: >=1.0.0
deprecatedThe package depends on the deprecated `redis` v2.x package, which is no longer actively maintained and lacks support for modern Redis features.
fix
Consider migrating to a package that uses `ioredis` or newer `redis` v4 for future-proofing.
affects: <=5.1.0
gotchaThe `keyPrefix` option does not automatically include a separator (e.g., colon). Keys are stored exactly as `<prefix><key>` without any delimiter.
fix
Include a separator in the prefix value, e.g., `keyPrefix: 'myapp:'`.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: RedisCache is not a constructor
Using incorrect import or require without proper instantiation.
fix
Ensure you import the named export: `import { RedisCache } from 'exp-rediscache'`.
Error: NOAUTH Authentication required.
Redis server requires password but none provided.
fix
Add `password` option to RedisCache constructor: `new RedisCache({ password: 'yourpassword' })`.
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server not running or unreachable.
fix
Start Redis: `redis-server` or adjust host/port options.
Upgrade
Version history
5.1.0latest on npm
Audit
Dependencies
redisrequiredThe underlying Redis client used for all cache operations. Version 2.x of redis is expected.
Agent activity
10 hits · last 30 days
node
8
Resources
exp-rediscache — npm install exp-rediscache · libregistry