workers-help
pages-help
general-help
durable-objects
workers-discussions
pages-discussions
wrangler
coding-help
kv
🦀rust-on-workers
miniflare
stream
general-discussions
functions
zaraz
âš¡instant-logs
email-routing
r2
pubsub-beta
analytics-engine
d1-database
queues
workers-for-platforms
workerd
web3
🤖turnstile
radar
web-research
logs-engine
cloudflare-go
terraform-provider-cloudflare
workers-ai
browser-rendering-api
analytics
next-on-pages
cloudflare-ai
build-caching-beta
hyperdrive
vectorize
ai-gateway
python-workers-beta
vitest-integration-beta
workers-observability
workflows-beta
You're quite close!
KV = "TEST"
assigns the string to the KV variable, instead of the KV namespace. In the old service worker syntax, removing this line would've been your solution, as bindings were global variables. In module workers (ones with export default
), they are available on the env
variable which is the second parameter of your fetch
function in line 4, so on line 5 and 6 you should change it to env.KV.put
and env.KV.get
.
- You'll need to actually bind your worker to this KV namespace you created, which in the dashboard you can do by clicking on Workers & Pages, selecting your worker, clicking on the Settings tab, and scrolling down to KV Namespace bindings. There, you'll need to select the KV namespace you created (Edit Variables, Add binding) and give it a name that it will be made available as (KV
in the example).
Saving it should create a new deployment where the namespace you selected is available as env.KV
And note too, if you are using local dev
id
Cloudflare incident on October 30, 2023
Hey team. We are seeing an interesting
kb.delete
call would have actually removed a real key from the store....I m having a problem with my KV Cache I
Hey so sorry clearly I didn t explain
Your findings are not wrong there is
KV is pull based so the data is stored
.get
runs in for 60 seconds (default) - you can cache it for longer with .get(key, { cacheTtl: seconds });
if you wasn't already
it depends what you're doing though - some things are faster to do in the worker everytime than they might be to cache in Cache API/KV & pull from...No You would have to store the value in
ToS and non-HTML content
I know I saw this in here before but