get/set values from Uint8Array
shamblesides opened this issue ยท 4 comments
It looks like this library mainly deals with strings, but I have some binary data that I'm storing in Redis. Is there currently a way to store/retrieve it, or is that not implemented?
Hi @shamblesides, thank you for reporting this issue! deno-redis
does not currently support Uint8Array
, but I think it would be nice to support it. ๐ I'll consider implementing it! ๐
Related to #133.
Sounds good! In the meantime I wrote my own custom minimal redis client using some of the code here as reference; hooray for the simplicity of RESP!
Limited support for getting/setting Uint8Array
values has been added in v0.21.0!
You can use BulkReply#buffer
(returned by Redis.executor.exec
) to get Uint8Array
values:
import { connect, replyTypes } from "https://deno.land/x/redis@v0.21.0/mod.ts";
import { assert, assertEquals } from "https://deno.land/std@0.91.0/testing/asserts.ts";
const redis = await connect({
hostname: "127.0.0.1",
port: 6379,
});
const encoder = new TextEncoder();
await redis.set("key", encoder.encode("hello"));
const reply = await redis.executor.exec("GET", "key");
assert(reply.type === replyTypes.BulkString);
assertEquals(reply.buffer(), encoder.encode("hello"));
that should work for me! thank you!