{"id":46544,"library":"streaming-cache","title":"streaming-cache","description":"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.","status":"maintenance","version":"0.5.5","language":"javascript","source_language":"en","source_url":"https://github.com/LaurentZuijdwijk/streaming-cache","tags":["javascript","cache","streams","queue"],"install":[{"cmd":"npm install streaming-cache","lang":"bash","label":"npm"},{"cmd":"yarn add streaming-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add streaming-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Underlying LRU cache for storing stream data","package":"lru-cache","optional":false}],"imports":[{"note":"Package uses CommonJS only; no ESM exports.","wrong":"import Cache from 'streaming-cache';","symbol":"Cache","correct":"const Cache = require('streaming-cache');"},{"note":"Default import is correct with ESM module resolution but package is CJS.","wrong":"import { Cache } from 'streaming-cache';","symbol":"Cache","correct":"import Cache from 'streaming-cache';"}],"quickstart":{"code":"const Cache = require('streaming-cache');\nconst fs = require('fs');\n\nconst cache = new Cache();\n\nconst readStream = fs.createReadStream('input.txt');\nconst writeStream1 = fs.createWriteStream('output1.txt');\nconst writeStream2 = fs.createWriteStream('output2.txt');\n\n// Pipe source into cache\nreadStream.pipe(cache.set('myKey'));\n\n// Later, retrieve the same stream and pipe to a different output\nsetTimeout(() => {\n  const cachedStream = cache.get('myKey');\n  if (cachedStream) {\n    cachedStream.pipe(writeStream2);\n  }\n}, 500);\n\n// Alternative: pipe directly on set()\n// cache.set('myKey2').pipe(writeStream1);","lang":"javascript","description":"Demonstrates creating a cache, writing a stream into it, then retrieving and piping it to a different output asynchronously."},"warnings":[{"fix":"If you need multiple consumers, pipe the cached stream to a PassThrough for each consumer, or use set() again.","message":"Cache.get() returns the stream only once; subsequent calls return undefined.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure cache size is sufficient for your workload; consider using an unbounded cache for critical streams.","message":"The LRU cache evicts entries if the cache is full, potentially losing active streams.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always pipe or end the writable side of the Duplex stream returned by set().","message":"set() returns a Duplex stream that must be properly ended to avoid memory leaks.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.5.5':35 '2019':45 'abil':80 'cach':3,8,15,68,73,86,90 'complet':87 'current':31 'data':21 'databas':60 'deliveri':18 'differenti':77 'download':58 'enabl':16 'even':22 'file':88 'fix':65 'fixed-s':64 'focus':47 'immedi':17 'javascript':89 'key':76 'last':40 'latenc':51 'librari':6 'like':38,56 'low':50 'low-lat':49 'lru':14,67,72 'lru-cach':71 'node.js':5 'packag':74 'queri':61 'queue':92 'releas':41 'replay':10,82 'reus':52 's3':57 'sinc':44 'size':66 'slow':54 'sourc':25 'stabl':32 'still':28 'stream':2,11,20,26,55,84,91 'streaming-cach':1 'unfinish':83 'unlik':85 'updat':43 'use':12,62 'version':33 'written':30","created_at":"2026-06-07T13:00:26.582479+00:00","updated_at":"2026-06-07T13:00:26.582479+00:00","problems":[{"fix":"Use: const Cache = require('streaming-cache'); const cache = new Cache(); cache.get('key');","cause":"Importing the module incorrectly or forgetting to create a Cache instance.","error":"TypeError: cache.get is not a function"},{"fix":"Ensure the destination is a writable stream (e.g., fs.createWriteStream or through2).","cause":"Trying to pipe into a non-stream object or a null stream.","error":"TypeError: dest.on is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/LaurentZuijdwijk/streaming-cache#readme","github":"https://github.com/LaurentZuijdwijk/streaming-cache","docs":null,"changelog":null,"pypi":null,"npm":"streaming-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}