Registry / storage / node-red-contrib-cache

node-red-contrib-cache

JSON →
library2.0.3jsnpmunverified

Node-RED nodes for in-memory caching with TTL support, version 2.0.3 (stable, last updated 2021). Provides three nodes: a Cache configuration node, a Cache in node for retrieval, and a Cache out node for storage with optional TTL (in seconds). Uses node-cache under the hood, but simplifies the API for Node-RED flows. Supports cache miss routing to a separate output and dumping all cache entries. Maintenance release with minor fixes.

npm install node-red-contrib-cache
INSTALL
IMPORT
SIG · NODE-RED-CONTRIB-C
N
node-red-contrib-cache
storagejavascriptv2.0.3
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.

Cache
Not applicable – nodes are loaded automatically by Node-RED from .js files in the package
import { Cache } from 'node-red-contrib-cache'
Node-RED nodes are not imported via JavaScript; they are auto-discovered by Node-RED runtime when installed. No manual import needed.

Install package, use Cache in/out nodes in Node-RED flow editor. Key in msg.topic, value in msg.payload.

// No code to write—install the package, then use the nodes in the editor. // Example flow (JSON): [{"id":"n1","type":"cache","name":"MyCache"},{"id":"n2","type":"cache in","z":"flow","cache":"n1","x":300,"y":200,"wires":[["n3"]]},{"id":"n3","type":"debug","z":"flow","name":"debug","active":true}] // To use: drag Cache in and Cache out nodes from palette, connect to a Cache config node. // Cache out node stores msg.payload with key msg.topic and optional TTL in msg.ttl (seconds). // Cache in node retrieves by msg.topic; emits ßnull if none exists or miss routing disabled. // Enable 'Route on miss' in Cache node config to get separate output for cache misses.
Debug
Known issues
breakingFrom 2.0.0, cache miss routing is disabled by default, changing previous behavior where no separate output existed.
fix
Enable 'Route on miss' in Cache node config to get miss output. Flows created before 2.0.0 will not automatically have miss routing.
affects: >=2.0.0 <2.0.3
deprecatedThe node emits null when retrieved value is null, undefined, or empty string since 1.0.3; this may cause confusion when expecting undefined.
fix
Check for null explicitly in downstream nodes.
affects: >=1.0.3 <2.0.3
gotchaDefault TTL of 0 immediately clears cache entries per 2.0.1 documentation; behavior may differ from expectations.
fix
Avoid setting Default TTL to 0 in Cache config; use undefined for no expiry.
affects: >=2.0.1
gotchaCache nodes require explicit Cache configuration node; multiple Cache nodes share the same cache instance if they reference the same config node.
fix
Create separate Cache config nodes for isolated caches.
affects: >=1.0.0
Errors
Common errors & fixes
Cache out node does not store value
Missing msg.topic or msg.payload not set
fix
Ensure msg.topic is set as the cache key and msg.payload is the value to store.
Cache in node returns null unexpectedly
Cache miss or key does not exist
fix
Use a 'Cache out' node to store the key first, or enable 'Route on miss' to handle misses separately.
TTL not working as expected
TTL in seconds but set as milliseconds or missing
fix
Provide TTL as integer seconds in msg.ttl. Default TTL is undefined (never expire).
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies
node-cacherequiredUnderlying cache implementation library
Agent activity
29 hits · last 30 days
node
28
Amazon
1
Resources
node-red-contrib-cache — npm install node-red-contrib-cache · libregistry