Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ For the purpose of this guide, you are going to use a [KV store](/kv/concepts/kv
Create two namespaces, one for production, and one for development.

```sh
npx wrangler kv:namespace create BROWSER_KV_DEMO
npx wrangler kv:namespace create BROWSER_KV_DEMO --preview
npx wrangler kv namespace create BROWSER_KV_DEMO
npx wrangler kv namespace create BROWSER_KV_DEMO --preview
```

Take note of the IDs for the next step.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ export default {
To verify the results, run the following command

```sh
npx wrangler kv:key get banana --binding KV --local
npx wrangler kv key get banana --binding KV --local
```
6 changes: 3 additions & 3 deletions src/content/docs/workers/local-development.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ The following [Wrangler commands](/workers/wrangler/commands/) have a `--local`
| Command |
| ---------------------------------------------------- |
| [`d1 execute`](/workers/wrangler/commands/#execute) |
| [`kv:key`](/workers/wrangler/commands/#kv-key) |
| [`kv:bulk`](/workers/wrangler/commands/#kv-bulk) |
| [`kv key`](/workers/wrangler/commands/#kv-key) |
| [`kv bulk`](/workers/wrangler/commands/#kv-bulk) |
| [`r2 object`](/workers/wrangler/commands/#r2-object) |

If using `--persist-to` to specify a custom folder with `wrangler dev` you should also add `--persist-to` with the same directory name along with the `--local` flag when running the commands above. For example, to put a custom KV key into a local namespace via the CLI you would run:

```sh
npx wrangler kv:key put test 12345 --binding MY_KV_NAMESPACE --local --persist-to worker-local
npx wrangler kv key put test 12345 --binding MY_KV_NAMESPACE --local --persist-to worker-local
```

Running `wrangler kv key put` will create a new key `test` with a value of `12345` on the local namespace specified via the binding `MY_KV_NAMESPACE` in the [Wrangler configuration file](/workers/wrangler/configuration/). This example command sets the local persistence directory to `worker-local` using `--persist-to`, to ensure that the data is created in the correct location. If `--persist-to` was not set, it would create the data in the `.wrangler` folder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ For the remainder of this tutorial you will complete each task, iterating on you

To begin, you need to understand how to populate your todo list with actual data. To do this, use [Cloudflare Workers KV](/kv/) — a key-value store that you can access inside of your Worker to read and write data.

To get started with KV, set up a namespace. All of your cached data will be stored inside that namespace and, with configuration, you can access that namespace inside the Worker with a predefined variable. Use Wrangler to create a new namespace called `TODOS` with the [`kv:namespace create` command](/workers/wrangler/commands/#kv-namespace-create) and get the associated namespace ID by running the following command in your terminal:
To get started with KV, set up a namespace. All of your cached data will be stored inside that namespace and, with configuration, you can access that namespace inside the Worker with a predefined variable. Use Wrangler to create a new namespace called `TODOS` with the [`kv namespace create` command](/workers/wrangler/commands/#kv-namespace-create) and get the associated namespace ID by running the following command in your terminal:

```sh title="Create a new KV namespace"
npx wrangler kv:namespace create "TODOS" --preview
npx wrangler kv namespace create "TODOS" --preview
```

The associated namespace can be combined with a `--preview` flag to interact with a preview namespace instead of a production namespace. Namespaces can be added to your application by defining them inside your Wrangler configuration. Copy your newly created namespace ID, and in your [Wrangler configuration file](/workers/wrangler/configuration/), define a `kv_namespaces` key to set up your namespace:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ In this tutorial, you will use Workers KV from Rust to build an app to store and
In the terminal, use Wrangler to create a KV namespace for `cities`. This generates a configuration to be added to the project:

```sh
npx wrangler kv:namespace create cities
npx wrangler kv namespace create cities
```

To add this configuration to your project, open the Wrangler file and create an entry for `kv_namespaces` above the build command:
Expand Down
Loading