Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support Uint8Array values for zero-copy transfer to worker_threads #3106

Open
@akaNightmare

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]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /