Can I use deno KV in worker?
It looks work, but does not persist at all.
See my sample code below.
Q1. why "key1" is not listed in my worker?
Q2. why "key2" always 1?
deno -vdeno 2.4.4
deno run --allow-read=. kvTest.tsI am NOT in a web worker { key: [ "key1" ], value: 8, versionstamp: "00000000000000e00000" } I am in a web worker { key: [ "key2" ], value: 1, versionstamp: "00000000000000090000" }
1 Reply
If your idea is to "share" a DB with a worker, you should always specify the DB file path, like
await Deno.openKv("mydb.db")
If you call Deno.openKv()
without arguments, a new DB will be created for each worker instance because they are isolated from each another