Skip to content

Commit 9a983b1

Browse files
committed
Drafting a more detailed Overview page for Workers KV.
1 parent abd5300 commit 9a983b1

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/content/docs/kv/index.mdx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
LinkTitleCard,
1313
Plan,
1414
RelatedProduct,
15+
Tabs,
16+
TabItem
1517
} from "~/components";
1618

1719
<Description>
@@ -24,6 +26,45 @@ Create a global, low-latency, key-value data storage.
2426

2527
Workers KV is a data storage that allows you to store and retrieve data globally. With Workers KV, you can build dynamic and performant APIs and websites that support high read volumes with low latency.
2628

29+
Workers KV is ideal for projects that require:
30+
31+
- High volumes of reads and/or repeated reads to the same keys.
32+
- Per-object time-to-live (TTL).
33+
- Distributed configuration.
34+
35+
For example, you can use Workers KV for:
36+
37+
- Caching API responses
38+
- Storing user configurations / preferences
39+
- Storing user authentication details
40+
41+
<Tabs>
42+
<TabItem label="index.ts">
43+
```ts
44+
export interface Env {
45+
BINDING_NAME: KVNamespace;
46+
}
47+
48+
export default {
49+
async fetch(request, env, ctx): Promise < Response > {
50+
await env.BINDING_NAME.put("KEY", "VALUE");
51+
const value = await env.BINDING_NAME.get("KEY");
52+
const allKeys = await env.BINDING_NAME.list();
53+
await env.BINDING_NAME.delete("KEY");
54+
return new Response(JSON.stringify({
55+
value: value,
56+
allKeys: allKeys
57+
}), {
58+
headers: {
59+
"A":"B"
60+
});
61+
},
62+
}
63+
satisfies ExportedHandler < Env > ;
64+
```
65+
</TabItem>
66+
</Tabs>
67+
2768
---
2869
2970
## Features

0 commit comments

Comments
 (0)