Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/content/docs/kv/api/read-key-value-pairs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ The following methods are provided to read from KV:
To get the value for a given key, call the `get()` method on any KV namespace you have bound to your Worker code:

```js
env.NAMESPACE.get(key, type?, options?);
env.NAMESPACE.get(key, type?);
// OR
env.NAMESPACE.get(key, options?);
```

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`.
Expand All @@ -58,10 +60,10 @@ The `get()` method returns a promise you can `await` on to get the value. If the
- `type`: `"text" | "json" | "arrayBuffer" | "stream"`
- Optional. The type of the value to be returned. `text` is the default.
- `options`: `{
cacheTtl: number,
type: "text" | "json" | "arrayBuffer" | "stream"
cacheTtl?: number,
type?: "text" | "json" | "arrayBuffer" | "stream"
}`
- 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.
- 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.

#### Response

Expand All @@ -79,7 +81,9 @@ The `get()` method may return stale values. If a given key has recently been rea
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:

```js
env.NAMESPACE.getWithMetadata(key, type?, options?);
env.NAMESPACE.getWithMetadata(key, type?);
// OR
env.NAMESPACE.getWithMetadata(key, options?);
```

Metadata is a serializable value you append to each KV entry.
Expand All @@ -91,10 +95,10 @@ Metadata is a serializable value you append to each KV entry.
- `type`: `"text" | "json" | "arrayBuffer" | "stream"`
- Optional. The type of the value to be returned. `text` is the default.
- `options`: `{
cacheTtl: number,
type: "text" | "json" | "arrayBuffer" | "stream"
cacheTtl?: number,
type?: "text" | "json" | "arrayBuffer" | "stream"
}`
- 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.
- 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.

#### Response

Expand Down
Loading