Registry / storage / redis-wstream

redis-wstream

JSON →
library1.0.0jsnpmunverified

A Node.js write stream that pipes binary or UTF-8 data into a Redis key using an existing Redis client. Tests with mranney/node_redis, streams2 compatible (Node >=4). Stabilizes at v1.0.0 with low release cadence. Differentiates from other Redis stream implementations by reusing an existing client connection instead of opening its own, enabling shared authentication and connection pooling.

npm install redis-wstream
INSTALL
IMPORT
SIG · REDIS-WSTREAM
R
redis-wstream
storagejavascriptv1.0.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.

redisWStream
const redisWStream = require('redis-wstream');
import redisWStream from 'redis-wstream';
Package is CJS only; no default ESM export.
redisWStream
const stream = redisWStream(client, 'key', options);
const stream = new redisWStream(client, 'key');
Factory function, not a constructor.
options.clientMulti
const opts = { clientMulti: client.multi() };
const opts = { clientMulti: client };
Must be a multi/batch client, not a normal client.

Creates a Redis write stream, pipes a file stream into it, and saves data to a Redis key. Uses environment variable for Redis host.

const redis = require('redis'); const redisWStream = require('redis-wstream'); const client = redis.createClient({ host: process.env.REDIS_HOST ?? 'localhost' }); const readStream = require('fs').createReadStream('data.txt'); const writeStream = redisWStream(client, 'mykey'); readStream.pipe(writeStream).on('finish', () => { console.log('Data saved to Redis key mykey'); client.quit(); }); writeStream.on('error', (err) => console.error('Stream error:', err));
Debug
Known issues
gotchaUsing a normal (non-multi) client causes in-memory accumulation of the entire stream before sending to Redis.
fix
Pass `options.clientMulti` with a multi client to batch operations.
affects: >=0.0.0
gotchaThe `tempKeySuffix` must be unique per concurrent write to the same key to avoid collisions.
fix
Omit or use a unique suffix per stream.
affects: >=0.0.0
breakingRequires Node >=4.0.0 (streams2).
fix
Upgrade Node.js to >=4.0.0.
affects: >=1.0.0
deprecatedNode 0.8 compatibility was dropped in v1.0.0.
fix
Use v1.0.0 only on Node >=4.0.0.
affects: <1.0.0
gotchaThe 'end' event is not emitted; use 'finish' for completion.
fix
Listen to the 'finish' event instead of 'end'.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: redisWStream is not a constructor
Using `new redisWStream(...)` which is incorrect.
fix
Call `redisWStream(client, key)` without `new`.
Error: Redis connection to localhost:6379 failed
Redis server not running or host/port wrong.
fix
Start Redis server or set correct host/port in `redis.createClient()`.
write after end
Stream ended prematurely due to error or close.
fix
Check for errors on the read stream or write stream, and ensure proper error handling.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
redisrequiredPeer dependency: required for the Redis client instance passed to the stream factory.
Agent activity
24 hits · last 30 days
node
22
Amazon
1
Resources
redis-wstream — npm install redis-wstream · libregistry