Where is the database saved and opened in Deno KV?

93 Views Asked by At

I have always thought that Deno KV is an SaaS as it has a price, and thus is stored only on the cloud. This assumption has never been challenged since every time I use openKv without any parameter I can set and get entries to or from Deno KV just fine:

const kv = await Deno.openKv();
const a = await kv.get(["preferences", "ada"]);
console.log(a);
// Result: {"key":["preferences","ada"],"value":{"username":"ada","theme":"dark","language":"en-US"},"versionstamp":"00000000000000090000"}

Today, when I run routes/test.tsx with Fresh, the data is null:

export const handler: Handlers = {
  async GET(req, ctx) {
    const kv = await Deno.openKv();
    const a = await kv.get(["preferences", "ada"]);
    console.log(a);
    return ctx.render({ a });
  },
};
// Result: {"key":["preferences","ada"],"value":null,"versionstamp":null}

From Deno.openKv | Runtime APIs | Deno:

When no path is provided, the database will be opened in a default path for the current script. This location is persistent across script runs and is keyed on the origin storage key (the same key that is used to determine localStorage persistence). More information about the origin storage key can be found in the Deno Manual.

I look at the manual and the article Web Storage API | Deno Docs seems to be about that. But I don't understand what it says.

So, where is exactly the database stored? Is it on the cloud or on my machine?

0

There are 0 best solutions below