1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { blob } from "https://esm.town/v/std/blob?v=11";
import { blobStore } from "https://esm.town/v/vladimyr/keyvhqBlob";
import Keyv from "npm:@keyvhq/core";
const keyv = new Keyv({ store: blobStore, namespace: "main" });
const keyv2 = new Keyv({ store: blobStore, namespace: "other" });
await keyv.set("foo", "bar");
console.log(await keyv.get("foo"));
await keyv.set("baz", { num: 42, str: "hello" });
console.log(await keyv.get("baz"));
await keyv.set("temp", "test");
await keyv.delete("temp");
console.log();
for await (const [key, val] of keyv.iterator()) {
console.log("%s=%o", key, val);
}
await keyv2.set("keyv", "is cool");
console.log();
const result = await blob.getJSON("keyv");
console.log(result);
console.log();
{
await keyv.clear();
const result = await blob.getJSON("keyv");
console.log(result);
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
April 1, 2024