Support Uint8Array values for zero-copy transfer to worker_threads
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.6k
- Forks
- 2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 40
Description
Motivation
Currently, Redis values are returned as Buffer, which requires manual conversion or copying when sending data to worker_threads.
To enable zero-copy transfer, it would be great to support Uint8Array as a return type.
Internally, the implementation may use new TextEncoder().encode(redisRes) or similar logic when encoding strings to Uint8Array.
Basic Code Example
const redis = await createClient({ url: 'redis://localhost:7777' })
.on("error", (err) => console.log("Redis Client Error", err))
.connect();
const rawData = await fs.readFile('./package.json');
await redis.set('__foo1', rawData);
const res = await redis.withTypeMapping({
[RESP_TYPES.BLOB_STRING]: Uint8Array,
}).get('__foo1');
worker.postMessage(res, [res.buffer]);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing withTypeMapping and RESP_TYPES.BLOB_STRING handling in the node-redis codebase, then inspect how values are returned from get(). Use the worker_threads postMessage example as the behavioral check; done means a mapped Uint8Array can be transferred without manual conversion or copying.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, redis, typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100