Registry / storage / cache-all

cache-all

JSON →
library2.1.1jsnpmunverified

A multi-engine caching library for Node.js and Express, providing in-memory, file, and Redis backends with a singleton pattern. Current version 2.1.1 (stable, maintenance mode). Released 2022. Differentiators: unified API across engines, Express middleware for route caching, pattern-based cache invalidation, promise-based async operations. Alternatives like node-cache-manager offer more backends but lack Express integration.

npm install cache-all
INSTALL
IMPORT
SIG · CACHE-ALL
C
cache-all
storagejavascriptv2.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.

default (in-memory)
import cache from 'cache-all'
const cache = require('cache-all')
Default import works with both ESM and CJS. For explicit engine, import from subpath.
default (file)
import cache from 'cache-all/file'
default (redis)
import cache from 'cache-all/redis'
Requires optional dependency 'redis'.

Initializes default in-memory cache, sets and gets keys with optional TTL, removes a key, and retrieves all entries.

import cache from 'cache-all'; await cache.init({ ttl: 300 }); await cache.set('greeting', 'Hello World'); const greeting = await cache.get('greeting'); console.log(greeting); await cache.set('count', 42, 120); const count = await cache.get('count'); console.log(count); await cache.remove('greeting'); const all = await cache.getAll(); console.log(all);
Debug
Known issues
deprecatedcache.has() is deprecated; use cache.get() and check for null.
fix
Replace cache.has(key) with await cache.get(key) !== null
affects: >=2.0.0
gotchacache.init() must be called before any get/set operations or they will fail
fix
Always await cache.init() at startup before using cache
affects: >=1.0.0
gotchaMultiple engines cannot coexist due to singleton pattern; calling init with different config overwrites previous instance
fix
Use separate cache instances via the factory pattern or use different libraries for different engines
affects: >=2.0.0
Errors
Common errors & fixes
ERR_AVALIABLE_CACHE: cache engine not found
Attempting to use an engine without calling init()
fix
Call cache.init({...}) before any cache operations.
TypeError: cache.set is not a function
Importing wrong module path or not awaiting init
fix
Use correct import path (e.g., 'cache-all/redis') and ensure init is awaited.
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies
redisoptionalRequired for Redis engine (require('cache-all/redis'))
Agent activity
34 hits · last 30 days
node
32
OpenAI (training)
1
Resources
cache-all — npm install cache-all · libregistry