本页还没有译文
本页 77 段还没译成Español,下面显示的是英文原文。KV
还没翻译译自英文(developers.cloudflare.com)本页 77 段都还没译
Manage Workers KV using Wrangler.
kv namespace
Manage Workers KV namespaces.
Note
The kv ... commands allow you to manage your Workers KV resources in the Cloudflare network. Learn more about using Workers KV with Wrangler in the Workers KV guide.
Caution
Since version 3.60.0, Wrangler supports the kv ... syntax. If you are using versions below 3.60.0, the command follows the kv:... syntax. Learn more about the deprecation of the kv:... syntax in the Wrangler commands for KV page.
kv namespace create
Create a new namespace
npx wrangler kv namespace create <NAMESPACE>yarn wrangler kv namespace create <NAMESPACE>pnpm wrangler kv namespace create <NAMESPACE>-
<NAMESPACE>string requiredThe name of the new namespace
-
--previewbooleanInteract with a preview namespace
-
--jurisdictionstringThe jurisdiction where the new namespace will be created (e.g. "us", "eu", "fedramp")
-
--use-remotebooleanUse a remote binding when adding the newly created resource to your config
-
--update-configbooleanAutomatically update your config file with the newly added resource
-
--bindingstringThe binding name of this resource in your Worker
To restrict where a namespace durably stores data, specify --jurisdiction when creating it. Refer to Data location for supported jurisdictions.
KV Instant namespaces
Note
Workers KV Instant is currently in private beta. To enroll, contact your Cloudflare account team or sign up and tell us about your use case.
To create a Workers KV Instant namespace, pass --experimental-mode instant. This example creates a namespace named APP_CONFIG for small, infrequently updated configuration:
npx wrangler@latest kv namespace create APP_CONFIG --experimental-mode instantyarn wrangler@latest kv namespace create APP_CONFIG --experimental-mode instantpnpm wrangler@latest kv namespace create APP_CONFIG --experimental-mode instantYou can also use the --x-mode instant alias.
kv namespace list
Output a list of all KV namespaces associated with your account id
npx wrangler kv namespace listyarn wrangler kv namespace listpnpm wrangler kv namespace listkv namespace delete
Delete a given namespace.
npx wrangler kv namespace delete [NAMESPACE]yarn wrangler kv namespace delete [NAMESPACE]pnpm wrangler kv namespace delete [NAMESPACE]-
[NAMESPACE]stringThe name of the namespace to delete
-
--bindingstringThe binding name to the namespace to delete from
-
--namespace-idstringThe id of the namespace to delete
-
--previewbooleanInteract with a preview namespace
-
--skip-confirmationboolean alias: --y default: falseSkip confirmation
kv namespace rename
Rename a KV namespace
npx wrangler kv namespace rename [OLD-NAME]yarn wrangler kv namespace rename [OLD-NAME]pnpm wrangler kv namespace rename [OLD-NAME]-
[OLD-NAME]stringThe current name of the namespace to rename
-
--namespace-idstringThe id of the namespace to rename
-
--new-namestring requiredThe new name for the namespace
kv key
Manage key-value pairs within a Workers KV namespace.
Note
The kv ... commands allow you to manage your Workers KV resources in the Cloudflare network. Learn more about using Workers KV with Wrangler in the Workers KV guide.
Caution
Since version 3.60.0, Wrangler supports the kv ... syntax. If you are using versions below 3.60.0, the command follows the kv:... syntax. Learn more about the deprecation of the kv:... syntax in the Wrangler commands for KV page.
kv key put
Write a single key/value pair to the given namespace
npx wrangler kv key put <KEY> [VALUE]yarn wrangler kv key put <KEY> [VALUE]pnpm wrangler kv key put <KEY> [VALUE]-
<KEY>string requiredThe key to write to
-
[VALUE]stringThe value to write
-
--pathstringRead value from the file at a given path
-
--bindingstringThe binding name to the namespace to write to
-
--namespace-idstringThe id of the namespace to write to
-
--previewbooleanInteract with a preview namespace
-
--ttlnumberTime for which the entries should be visible
-
--expirationnumberTime since the UNIX epoch after which the entry expires
-
--metadatastringArbitrary JSON that is associated with a key
-
--localbooleanInteract with local storage
-
--remotebooleanInteract with remote storage
-
--persist-tostringDirectory for local persistence
kv key list
Output a list of all keys in a given namespace
npx wrangler kv key listyarn wrangler kv key listpnpm wrangler kv key list-
--bindingstringThe binding name to the namespace to list
-
--namespace-idstringThe id of the namespace to list
-
--previewboolean default: falseInteract with a preview namespace
-
--prefixstringA prefix to filter listed keys
-
--localbooleanInteract with local storage
-
--remotebooleanInteract with remote storage
-
--persist-tostringDirectory for local persistence
kv key get
Read a single value by key from the given namespace
npx wrangler kv key get <KEY>yarn wrangler kv key get <KEY>pnpm wrangler kv key get <KEY>-
<KEY>string requiredThe key value to get.
-
--textboolean default: falseDecode the returned value as a utf8 string
-
--bindingstringThe binding name to the namespace to get from
-
--namespace-idstringThe id of the namespace to get from
-
--previewboolean default: falseInteract with a preview namespace
-
--localbooleanInteract with local storage
-
--remotebooleanInteract with remote storage
-
--persist-tostringDirectory for local persistence
kv key delete
Remove a single key value pair from the given namespace
npx wrangler kv key delete <KEY>yarn wrangler kv key delete <KEY>pnpm wrangler kv key delete <KEY>-
<KEY>string requiredThe key value to delete.
-
--bindingstringThe binding name to the namespace to delete from
-
--namespace-idstringThe id of the namespace to delete from
-
--previewbooleanInteract with a preview namespace
-
--localbooleanInteract with local storage
-
--remotebooleanInteract with remote storage
-
--persist-tostringDirectory for local persistence
kv bulk
Manage multiple key-value pairs within a Workers KV namespace in batches.
Note
The kv ... commands allow you to manage your Workers KV resources in the Cloudflare network. Learn more about using Workers KV with Wrangler in the Workers KV guide.
Caution
Since version 3.60.0, Wrangler supports the kv ... syntax. If you are using versions below 3.60.0, the command follows the kv:... syntax. Learn more about the deprecation of the kv:... syntax in the Wrangler commands for KV page.
kv bulk get
Gets multiple key-value pairs from a namespace
npx wrangler kv bulk get <FILENAME>yarn wrangler kv bulk get <FILENAME>pnpm wrangler kv bulk get <FILENAME>-
<FILENAME>string requiredThe file containing the keys to get
-
--bindingstringThe binding name to the namespace to get from
-
--namespace-idstringThe id of the namespace to get from
-
--previewboolean default: falseInteract with a preview namespace
-
--localbooleanInteract with local storage
-
--remotebooleanInteract with remote storage
-
--persist-tostringDirectory for local persistence
kv bulk put
Upload multiple key-value pairs to a namespace
npx wrangler kv bulk put <FILENAME>yarn wrangler kv bulk put <FILENAME>pnpm wrangler kv bulk put <FILENAME>-
<FILENAME>string requiredThe file containing the key/value pairs to write
-
--bindingstringThe binding name to the namespace to write to
-
--namespace-idstringThe id of the namespace to write to
-
--previewbooleanInteract with a preview namespace
-
--ttlnumberTime for which the entries should be visible
-
--expirationnumberTime since the UNIX epoch after which the entry expires
-
--metadatastringArbitrary JSON that is associated with a key
-
--localbooleanInteract with local storage
-
--remotebooleanInteract with remote storage
-
--persist-tostringDirectory for local persistence
kv bulk delete
Delete multiple key-value pairs from a namespace
npx wrangler kv bulk delete <FILENAME>yarn wrangler kv bulk delete <FILENAME>pnpm wrangler kv bulk delete <FILENAME>-
<FILENAME>string requiredThe file containing the keys to delete
-
--forceboolean alias: --fDo not ask for confirmation before deleting
-
--bindingstringThe binding name to the namespace to delete from
-
--namespace-idstringThe id of the namespace to delete from
-
--previewbooleanInteract with a preview namespace
-
--localbooleanInteract with local storage
-
--remotebooleanInteract with remote storage
-
--persist-tostringDirectory for local persistence