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".
No description
16 Replies
BrianBall
BrianBallOP3mo ago
It does work with the ID - but, I'm just reporting broken documentation continuity.
JamieD132
JamieD1323mo ago
help I am trying to import kv to my javascript worker with import { KVNameSpace } from '@cloudflare/kv-name-space' but it doesn;t work
tadhglewis
tadhglewis3mo ago
it doesn;t work
@JamieD132 What is the error you're getting and what do you expect to get?
tadhglewis
tadhglewis3mo ago
The package mentioned doesn't even exist 🤷 https://www.npmjs.com/package/@cloudflare/kv-name-space
kindaraffy
kindaraffy3mo ago
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
Marcus
Marcus3mo ago
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 worker
thomasgauvin
thomasgauvin3mo ago
Thanks 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>
kindaraffy
kindaraffy3mo ago
Thank you.
carlos-alberto
carlos-alberto3mo ago
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.
carlos-alberto
carlos-alberto3mo ago
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
thomasgauvin
thomasgauvin3mo ago
DM'd
ItsWendell
ItsWendell3mo ago
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!
thomasgauvin
thomasgauvin3mo ago
Thanks for the feedback @ItsWendell, like you mentioned, KV doesn't have cache purges but it's something we're keeping our eyes on
w3bcode
w3bcode3mo ago
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
Hello, I’m Allie!
No, since it does not expose an HTTP API
Want results from more Discord servers?
Add your server