Skip to content

Commit 7974715

Browse files
authored
Apply suggestions from code review
Style guide alignment
1 parent 78e6c00 commit 7974715

File tree

4 files changed

+23
-24
lines changed

4 files changed

+23
-24
lines changed

src/content/docs/kv/examples/cache-data-with-workers-kv.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ description: Example of how to use Workers KV to build a distributed application
1313
import { Render, PackageManagers, Tabs, TabItem } from "~/components";
1414

1515
Workers KV can be used as a persistent, single, global cache accessible from Cloudflare Workers to speed up your application.
16-
Data cached in Workers KV will be accessible from all other Cloudflare locations as well and will be persisted until expiry or deletion.
16+
Data cached in Workers KV is accessible from all other Cloudflare locations as well, and persists until expiry or deletion.
1717

1818
After fetching data from external resources in your Workers application, you can write the data to Workers KV.
1919
On subsequent Worker requests (in the same region or in other regions), you can read the cached data from Workers KV instead of calling the external API.
20-
This improves your Worker application's performance and resilience while reducing load on the external resource.
20+
This improves your Worker application's performance and resilience while reducing load on external resources.
2121

2222
This example shows how you can cache data in Workers KV and read cached data from Workers KV in a Worker application.
2323

src/content/docs/kv/examples/distributed-configuration-with-workers-kv.mdx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Render, PackageManagers, Tabs, TabItem } from "~/components";
1414

1515
Storing application configuration data is an ideal use case for Workers KV. Configuration data can include data to personalize an application for each user or tenant, enable features for user groups, restrict access with allow-lists/deny-lists, etc. These use-cases can have high read volumes that are highly cacheable by Workers KV, which can ensure low-latency reads from your Workers application.
1616

17-
In this example, application configuration data is used to personalize the Workers application for each user. The configuration data is stored in an external application and database and written to Workers KV using the REST API.
17+
In this example, application configuration data is used to personalize the Workers application for each user. The configuration data is stored in an external application and database, and written to Workers KV using the REST API.
1818

1919
## Write your configuration from your external application to Workers KV
2020

@@ -221,19 +221,15 @@ export default {
221221
</TabItem>
222222
</Tabs>
223223

224-
This code will use the path within the URL and find the file associated to the path within the KV store. It also sets the proper MIME type in the response to indicate to the browser how to handle the response. To retrieve the value from the KV store, this code uses `arrayBuffer` to properly handle binary data such as images, documents, and video/audio files.
224+
This code will use the path within the URL and find the file associated to the path within the KV store. It also sets the proper MIME type in the response to inform the browser how to handle the response. To retrieve the value from the KV store, this code uses `arrayBuffer` to properly handle binary data such as images, documents, and video/audio files.
225225

226-
## Optimizing performance for configuration
226+
## Optimize performance for configuration
227227

228-
To optimize performance, you may opt to consolidate values in fewer key-value pairs. By doing so, you may
229-
benefit from higher caching efficiency and lower latency.
228+
To optimize performance, you may opt to consolidate values in fewer key-value pairs. By doing so, you may benefit from higher caching efficiency and lower latency.
230229

231-
For example, instead of storing each user's configuration
232-
in a separate key-value pair, you may store all users' configurations in a single key-value pair. This approach
233-
may be suitable for use-cases where the configuration data is small and can be easily managed in a single key-value pair
234-
(the [size limit for a Workers KV value is 25 MiB](/kv/platform/limits/)).
230+
For example, instead of storing each user's configuration in a separate key-value pair, you may store all users' configurations in a single key-value pair. This approach may be suitable for use-cases where the configuration data is small and can be easily managed in a single key-value pair (the [size limit for a Workers KV value is 25 MiB](/kv/platform/limits/)).
235231

236232
## Related resources
237233

238-
- [Rust support in Workers](/workers/languages/rust/).
239-
- [Using KV in Workers](/kv/get-started/).
234+
- [Rust support in Workers](/workers/languages/rust/)
235+
- [Using KV in Workers](/kv/get-started/)

src/content/docs/kv/examples/routing-with-workers-kv.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ description: Example of how to use Workers KV to build a distributed application
1212

1313
import { Render, PackageManagers, Tabs, TabItem } from "~/components";
1414

15-
Using Workers KV to store routing data to route requests across various web servers with Workers is an ideal use case for Workers KV.
16-
Routing workloads can have high read volume and Workers KV's low-latency reads can help ensure that routing decisions are made quickly and efficiently.
15+
Using Workers KV to store routing data to route requests across various web servers with Workers is an ideal use case for Workers KV. Routing workloads can have high read volume, and Workers KV's low-latency reads can help ensure that routing decisions are made quickly and efficiently.
1716

1817
Routing can be helpful to route requests coming into a single Cloudflare Worker application to different web servers based on the request's path, hostname, or other request attributes.
19-
In single-tenant applications, this can be used to route requests to various origin servers based on the business domain (ex: requests to `/admin` routed to administration server, `/store` routed to storefront server, `/api` routed to the API server).
20-
In multi-tenant applications, requests can be routed to the tenant's respective origin resources (ex: requests to `tenantA.your-worker-hostname.com` routed to server for Tenant A, `tenantB.your-worker-hostname.com` routed to server for Tenant B).
18+
19+
In single-tenant applications, this can be used to route requests to various origin servers based on the business domain (for example, requests to `/admin` routed to administration server, `/store` routed to storefront server, `/api` routed to the API server).
20+
21+
In multi-tenant applications, requests can be routed to the tenant's respective origin resources (for example, requests to `tenantA.your-worker-hostname.com` routed to server for Tenant A, `tenantB.your-worker-hostname.com` routed to server for Tenant B).
2122

2223
Routing can also be used to implement [A/B testing](/reference-architecture/diagrams/serverless/a-b-testing-using-workers/), canary deployments, or blue-green deployments for your own external applications.
2324
If you are looking to implement canary or blue-green deployments of applications built fully on Cloudflare Workers, see [Workers gradual deployments](/workers/configuration/versions-and-deployments/gradual-deployments/).
2425

25-
## Routing requests with Workers KV
26+
## Route requests with Workers KV
2627

2728
In this example, a multi-tenant e-Commerce application is built on Cloudflare Workers. Each storefront is a different tenant and has its own external web server.
2829
Our Cloudflare Worker is responsible for receiving all requests for all storefronts and routing requests to the correct origin web server according to the storefront ID.

src/content/docs/kv/examples/workers-kv-to-serve-assets.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ With [Workers KV](/kv), you can access, edit and store assets directly from your
2020

2121
## Write static assets to Workers KV using Wrangler
2222

23-
To store static assets in Workers KV, you can use the [Wrangler CLI](/workers/wrangler/) (commonly used during development), the [Workers KV binding](/kv/concepts/kv-bindings/) from a Workers application, or the [Workers KV REST API](/api/resources/kv/subresources/namespaces/methods/list/) (commonly used to access Workers KV from an external application). We'll demonstrate how to use the Wrangler CLI.
23+
To store static assets in Workers KV, you can use the [Wrangler CLI](/workers/wrangler/) (commonly used during development), the [Workers KV binding](/kv/concepts/kv-bindings/) from a Workers application, or the [Workers KV REST API](/api/resources/kv/subresources/namespaces/methods/list/) (commonly used to access Workers KV from an external application). We will demonstrate how to use the Wrangler CLI.
2424

25-
For this scenario, we'll be storing a sample HTML file within our Workers KV store. Create a new file `index.html` with the following content:
25+
For this scenario, we will store a sample HTML file within our Workers KV store.
26+
27+
Create a new file `index.html` with the following content:
2628

2729
```html title="index.html"
2830
Hello World!
@@ -118,7 +120,7 @@ export default {
118120
</TabItem>
119121
</Tabs>
120122
121-
This code parses the key name for the key-value pair to fetch from the HTTP request. Then, it determines the proper MIME type for the response to indicate to the browser how to handle the response.
123+
This code parses the key name for the key-value pair to fetch from the HTTP request. Then, it determines the proper MIME type for the response to inform the browser how to handle the response.
122124
To retrieve the value from the KV store, this code uses `arrayBuffer` to properly handle binary data such as images, documents, and video/audio files.
123125
124126
Given a sample key-value pair with key `index.html` with value containing some HTML content in our Workers KV namespace store, we can access our Workers application
@@ -130,7 +132,7 @@ Try it out with an image or a document and you will see that this Worker is also
130132

131133
In addition to serving static assets, we can also generate dynamic HTML or API responses based on the values stored in our KV store.
132134

133-
Start by creating this file in the root of your project:
135+
1. Start by creating this file in the root of your project:
134136

135137
```json title="hello-world.json"
136138
[
@@ -169,13 +171,13 @@ Start by creating this file in the root of your project:
169171
]
170172
```
171173

172-
Open a terminal and enter the following KV command to create a KV entry for the translations file:
174+
2. Open a terminal and enter the following KV command to create a KV entry for the translations file:
173175

174176
```sh
175177
npx wrangler kv key put hello-world.json --path hello-world.json --namespace-id=<ENTER_NAMESPACE_ID_HERE>
176178
```
177179

178-
Update your Workers code to add logic to serve a translated HTML file based on the language of the Accept-Language header of the request:
180+
3. Update your Workers code to add logic to serve a translated HTML file based on the language of the Accept-Language header of the request:
179181

180182
<Tabs>
181183
<TabItem label="index.ts">

0 commit comments

Comments
 (0)