A Node.js library that caches and replays streams using an LRU cache, enabling immediate delivery of streaming data even while the source stream is still being written. Current stable version is 0.5.5, which is likely the last release (no updates since 2019). It focuses on low-latency reuse of slow streams like S3 downloads or database queries, using a fixed-size LRU cache from the lru-cache package. Its key differentiator is the ability to replay unfinished streams, unlike caching complete files.
npm install streaming-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a cache, writing a stream into it, then retrieving and piping it to a different output asynchronously.
If you need multiple consumers, pipe the cached stream to a PassThrough for each consumer, or use set() again.
Ensure cache size is sufficient for your workload; consider using an unbounded cache for critical streams.
Always pipe or end the writable side of the Duplex stream returned by set().
Use: const Cache = require('streaming-cache'); const cache = new Cache(); cache.get('key');Ensure the destination is a writable stream (e.g., fs.createWriteStream or through2).