From eb4692dd3574aaffd0b857d21940d531695350ac Mon Sep 17 00:00:00 2001 From: Thomas Gauvin <35609369+thomasgauvin@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:38:58 -0500 Subject: [PATCH 1/5] Update read-key-value-pairs.mdx --- src/content/docs/kv/api/read-key-value-pairs.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/content/docs/kv/api/read-key-value-pairs.mdx b/src/content/docs/kv/api/read-key-value-pairs.mdx index a3d6f96462c86f1..ad00264e23d8e89 100644 --- a/src/content/docs/kv/api/read-key-value-pairs.mdx +++ b/src/content/docs/kv/api/read-key-value-pairs.mdx @@ -58,10 +58,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, + 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 `cacheTtl` and `type` properties. The optional `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 @@ -91,10 +91,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, + 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 `cacheTtl` and `type` properties. The optional `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 From 838cd81790a9db07df451b6f6281e7efac22be54 Mon Sep 17 00:00:00 2001 From: Thomas Gauvin <35609369+thomasgauvin@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:37:51 -0500 Subject: [PATCH 2/5] Update src/content/docs/kv/api/read-key-value-pairs.mdx --- src/content/docs/kv/api/read-key-value-pairs.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/kv/api/read-key-value-pairs.mdx b/src/content/docs/kv/api/read-key-value-pairs.mdx index ad00264e23d8e89..8ee7c43b69166f2 100644 --- a/src/content/docs/kv/api/read-key-value-pairs.mdx +++ b/src/content/docs/kv/api/read-key-value-pairs.mdx @@ -59,7 +59,7 @@ The `get()` method returns a promise you can `await` on to get the value. If the - Optional. The type of the value to be returned. `text` is the default. - `options`: `{ cacheTtl?: number, - type: "text" | "json" | "arrayBuffer" | "stream" + type?: "text" | "json" | "arrayBuffer" | "stream" }` - Optional. Object containing the `cacheTtl` and `type` properties. The optional `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. From 231525bb573953c30a529dacecf5a513fcbacf6a Mon Sep 17 00:00:00 2001 From: Thomas Gauvin <35609369+thomasgauvin@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:38:32 -0500 Subject: [PATCH 3/5] Update src/content/docs/kv/api/read-key-value-pairs.mdx --- src/content/docs/kv/api/read-key-value-pairs.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/kv/api/read-key-value-pairs.mdx b/src/content/docs/kv/api/read-key-value-pairs.mdx index 8ee7c43b69166f2..a68b83792f3a87d 100644 --- a/src/content/docs/kv/api/read-key-value-pairs.mdx +++ b/src/content/docs/kv/api/read-key-value-pairs.mdx @@ -92,7 +92,7 @@ Metadata is a serializable value you append to each KV entry. - Optional. The type of the value to be returned. `text` is the default. - `options`: `{ cacheTtl?: number, - type: "text" | "json" | "arrayBuffer" | "stream" + type?: "text" | "json" | "arrayBuffer" | "stream" }` - Optional. Object containing the `cacheTtl` and `type` properties. The optional `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. From 8011880eb71a221b321582dc8b70f21a4bfbf505 Mon Sep 17 00:00:00 2001 From: Thomas Gauvin <35609369+thomasgauvin@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:42:33 -0500 Subject: [PATCH 4/5] Add overloaded methods signatures --- src/content/docs/kv/api/read-key-value-pairs.mdx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/content/docs/kv/api/read-key-value-pairs.mdx b/src/content/docs/kv/api/read-key-value-pairs.mdx index a68b83792f3a87d..e71f8fd9cbed2f1 100644 --- a/src/content/docs/kv/api/read-key-value-pairs.mdx +++ b/src/content/docs/kv/api/read-key-value-pairs.mdx @@ -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`. @@ -61,7 +63,7 @@ The `get()` method returns a promise you can `await` on to get the value. If the cacheTtl?: number, type?: "text" | "json" | "arrayBuffer" | "stream" }` - - Optional. Object containing the `cacheTtl` and `type` properties. The optional `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 @@ -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. @@ -94,7 +98,7 @@ Metadata is a serializable value you append to each KV entry. cacheTtl?: number, type?: "text" | "json" | "arrayBuffer" | "stream" }` - - Optional. Object containing the `cacheTtl` and `type` properties. The optional `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 From d5b690f1295f00d0ae06bf4728e68862127113e4 Mon Sep 17 00:00:00 2001 From: Jun Lee Date: Thu, 21 Nov 2024 09:28:33 +0000 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Greg Brimble --- src/content/docs/kv/api/read-key-value-pairs.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/docs/kv/api/read-key-value-pairs.mdx b/src/content/docs/kv/api/read-key-value-pairs.mdx index e71f8fd9cbed2f1..1f90e20462135d3 100644 --- a/src/content/docs/kv/api/read-key-value-pairs.mdx +++ b/src/content/docs/kv/api/read-key-value-pairs.mdx @@ -47,7 +47,7 @@ To get the value for a given key, call the `get()` method on any KV namespace yo ```js env.NAMESPACE.get(key, type?); -//OR +// OR env.NAMESPACE.get(key, options?); ``` @@ -82,7 +82,7 @@ To get the value for a given key along with its metadata, call the `getWithMetad ```js env.NAMESPACE.getWithMetadata(key, type?); -//OR +// OR env.NAMESPACE.getWithMetadata(key, options?); ```