In the kv docs /getting-started I can't get this command to work: npx wrangler kv key put --bindin
In the kv docs /getting-started
I can't get this command to work:
npx wrangler kv key put --binding=<BINDING_NAME> "<KEY>" "<VALUE>"
just trying to follow the kv-tutorial
I used kv_binding_name - trying to follow the docs.
Though the docs say: name it BINDING_NAME - the very next step shows a create command with kv_binding_name
✘ [ERROR] A namespace with binding name "kv_binding_name" was not found in the configured "kv_namespaces".
✘ [ERROR] A namespace with binding name "kv-tutorial-kv_binding_name" was not found in the configured "kv_namespaces".
16 Replies
It does work with the ID - but, I'm just reporting broken documentation continuity.
help I am trying to import kv to my javascript worker with
import { KVNameSpace } from '@cloudflare/kv-name-space'
but it doesn;t workit doesn;t work@JamieD132 What is the error you're getting and what do you expect to get?
The package mentioned doesn't even exist 🤷 https://www.npmjs.com/package/@cloudflare/kv-name-space
Hi guys! The documentation is a little murky on this one, how do I specify the expiration on the KV PUT REST body? https://developers.cloudflare.com/api/operations/workers-kv-namespace-write-key-value-pair-with-metadata
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
Ooh yeah they should have an example body there, for sure. I assume it's the same as the
wrangler kv bulk put
entries: https://developers.cloudflare.com/workers/wrangler/commands/#kv-bulk-put
was that a suggestion from an AI tool? that's my best guess :D anyway, follow https://developers.cloudflare.com/kv/get-started/#3-bind-your-worker-to-your-kv-namespace and https://developers.cloudflare.com/kv/get-started/#5-access-your-kv-namespace-from-your-worker to use a KV namespace with a workerThanks for flagging! let me verify
@kindaraffy yes, expiration is supported in the REST API, we'll be fix that in docs
You can specify expiration or expirationTtl as a query param
So I can tell the users: https://api.cloudflare.com/client/v4
/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}?expiration=<secondsSinceEpoch>
or https://api.cloudflare.com/client/v4
/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}?expirationTtl=<secondsFromNow>
Thank you.
Hey! Are there documented (or undocumented) rate limits on number of writes to different KV keys from a worker (on the paid plan)? We are seeing 429s when we try to write a few thousand keys within a few seconds.
KV has 1 write per second per key limit from the binding https://developers.cloudflare.com/kv/platform/limits/ and the APIs have global rate limits https://developers.cloudflare.com/fundamentals/api/reference/limits/#:~:text=The%20global%20rate%20limit%20for,receiving%20a%20HTTP%20429%20response.
Do the api rate limits apply to calls made from a worker binding?
We are writing to different keys, so the 1 per second should not apply
DM'd
Related to the new upcoming cache purging changes, couldn't these also apply to KV?
https://blog.cloudflare.com/instant-purge/
Is it generally possible to purge a specific KV key? I think if a KV value is locally cached, and you update this it could in theory especially with the new purging system 'instantly' purge all regional KV caches right? Think this could bring quite some benefits to keep KV reads latency.
E.g. I need super quick access to a 'configuration' stored in KV, this 'configuration' is updated at most a couple of times a day. If we can keep this in the cache until this value is updated or deleted, it would speed up calls to KV a lot. Currently it's documented that KV updates do not purge KV caches, in this case it would be great if it did!
Thanks for the feedback @ItsWendell, like you mentioned, KV doesn't have cache purges but it's something we're keeping our eyes on
can we use https://github.com/cloudflare/cloudflare-typescript with local wrangler created kv namespace ?
GitHub
GitHub - cloudflare/cloudflare-typescript: The official Typescript ...
The official Typescript library for the Cloudflare API - cloudflare/cloudflare-typescript
No, since it does not expose an HTTP API