Skip to content

Commit e3a6f02

Browse files
thomasgauvinOxyjunGregBrimble
authored andcommitted
Update read-key-value-pairs.mdx (#18303)
* Update read-key-value-pairs.mdx * Update src/content/docs/kv/api/read-key-value-pairs.mdx * Update src/content/docs/kv/api/read-key-value-pairs.mdx * Add overloaded methods signatures * Apply suggestions from code review Co-authored-by: Greg Brimble <[email protected]> --------- Co-authored-by: Jun Lee <[email protected]> Co-authored-by: Greg Brimble <[email protected]>
1 parent d281158 commit e3a6f02

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/content/docs/kv/api/read-key-value-pairs.mdx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ The following methods are provided to read from KV:
4646
To get the value for a given key, call the `get()` method on any KV namespace you have bound to your Worker code:
4747

4848
```js
49-
env.NAMESPACE.get(key, type?, options?);
49+
env.NAMESPACE.get(key, type?);
50+
// OR
51+
env.NAMESPACE.get(key, options?);
5052
```
5153
5254
The `get()` method returns a promise you can `await` on to get the value. If the key is not found, the promise will resolve with the literal value `null`.
@@ -58,10 +60,10 @@ The `get()` method returns a promise you can `await` on to get the value. If the
5860
- `type`: `"text" | "json" | "arrayBuffer" | "stream"`
5961
- Optional. The type of the value to be returned. `text` is the default.
6062
- `options`: `{
61-
cacheTtl: number,
62-
type: "text" | "json" | "arrayBuffer" | "stream"
63+
cacheTtl?: number,
64+
type?: "text" | "json" | "arrayBuffer" | "stream"
6365
}`
64-
- Optional. Object containing the `cacheTtl` and `type` properties. The `cacheTtl` property defines the length of time in seconds that a KV result is cached in the global network location it is accessed from (minimum: 60). The `type` property defines the type of the value to be returned.
66+
- Optional. Object containing the optional `cacheTtl` and `type` properties. The `cacheTtl` property defines the length of time in seconds that a KV result is cached in the global network location it is accessed from (minimum: 60). The `type` property defines the type of the value to be returned.
6567
6668
#### Response
6769
@@ -79,7 +81,9 @@ The `get()` method may return stale values. If a given key has recently been rea
7981
To get the value for a given key along with its metadata, call the `getWithMetadata()` method on any KV namespace you have bound to your Worker code:
8082
8183
```js
82-
env.NAMESPACE.getWithMetadata(key, type?, options?);
84+
env.NAMESPACE.getWithMetadata(key, type?);
85+
// OR
86+
env.NAMESPACE.getWithMetadata(key, options?);
8387
```
8488
8589
Metadata is a serializable value you append to each KV entry.
@@ -91,10 +95,10 @@ Metadata is a serializable value you append to each KV entry.
9195
- `type`: `"text" | "json" | "arrayBuffer" | "stream"`
9296
- Optional. The type of the value to be returned. `text` is the default.
9397
- `options`: `{
94-
cacheTtl: number,
95-
type: "text" | "json" | "arrayBuffer" | "stream"
98+
cacheTtl?: number,
99+
type?: "text" | "json" | "arrayBuffer" | "stream"
96100
}`
97-
- Optional. Object containing the `cacheTtl` and `type` properties. The `cacheTtl` property defines the length of time in seconds that a KV result is cached in the global network location it is accessed from (minimum: 60). The `type` property defines the type of the value to be returned.
101+
- Optional. Object containing the optional `cacheTtl` and `type` properties. The `cacheTtl` property defines the length of time in seconds that a KV result is cached in the global network location it is accessed from (minimum: 60). The `type` property defines the type of the value to be returned.
98102
99103
#### Response
100104

0 commit comments

Comments
 (0)