Skip to main content
method Deno.Kv.prototype.set

Set the value for the given key in the database. If a value already exists for the key, it will be overwritten.

const db = await Deno.openKv();
await db.set(["foo"], "bar");

Optionally an expireIn option can be specified to set a time-to-live (TTL) for the key. The TTL is specified in milliseconds, and the key will be deleted from the database at earliest after the specified number of milliseconds have elapsed. Once the specified duration has passed, the key may still be visible for some additional time. If the expireIn option is not specified, the key will not expire.


key: KvKey
value: unknown
options: { expireIn?: number; }