Usage with other DenoKV Wrappers specifically KV-Toolbox #167
Replies: 1 comment 11 replies
-
I don't think there is any simple or obvious way either. The thing is, I'm not sure there is any need for them to work together either. kitsonk's kv-toolbox works great for what it does and can easily be used alongside kvdex if you so choose to. Just pass the same Deno.Kv instance to both of them. Since kvdex prefixes all keys, you shouldn't be afraid of them colliding. Moreover, depending on your use case, you might just be fine using serialized collections in kvdex. Have you tried this? It does something similar to kv-toolbox blob utilities by serializing values as a uint8array, compressing it, and then splitting it into multiple KV entries to surpass the 64Kb size limit. This should allow you to store blobs. I can give you an example: import { kvdex, collection, model } from "kvdex"
const kv = await Deno.openKv()
const db = kvdex(kv, {
// Note that your model doesn't have to be of type Uint8Array, you can store any value you wish
blobs: collection(model<Uint8Array>(), { serialize: "json" })
})
const blob = new TextEncoder().encode("foo bar baz")
const result = await db.blobs.add(blob) The only issue I can see with using serialized collections for this is that it performs an unnecessary serialize step under the hood because it is designed to work with any values, not just blobs. I hadn't actually given much thought to this specific case tbh. I will probably refactor this in the near future to just skip the serialize step for blobs, which should remove the performance hit. |
Beta Was this translation helpful? Give feedback.
-
Is there an way to use kvdex with VK-Toolbox's blob storage wrapper? Maybe its obvious and I'm not seeing it?
https://github.com/kitsonk/kv-toolbox/blob/main/blob.ts
Beta Was this translation helpful? Give feedback.
All reactions