I figured it out by reading throught the plugins docs it these ones should be updated to include you

I figured it out by reading throught the plugins docs it these ones should be updated to include you need to process like this
export default eventHandler(async (event) => {
const { ARCKV } = event.context.cloudflare.env;

console.log(ARCKV)
let test = await ARCKV.list()
console.log(test)

let ctr = (await ARCKV.get("counter")) || 0;
await ARCKV.put("counter", ++ctr % 100);

return `counter: ${(await ARCKV.get("counter")) || 0}`;
});
export default eventHandler(async (event) => {
const { ARCKV } = event.context.cloudflare.env;

console.log(ARCKV)
let test = await ARCKV.list()
console.log(test)

let ctr = (await ARCKV.get("counter")) || 0;
await ARCKV.put("counter", ++ctr % 100);

return `counter: ${(await ARCKV.get("counter")) || 0}`;
});
17 Replies
Jando
JandoOP4mo ago
you cant use the context as listed on the wrangler docs!
Jadugar_Jaggu
Jadugar_Jaggu4mo ago
got a KV GET Failed : 500 internal Server error 4 minute ago
Corentin
Corentin4mo ago
Hi there! When keys are removed due to TTL expiration using the expirationTtl option, do those removals count toward the delete request quota ? Thanks!
Arvind
Arvind4mo ago
Hello all! 👋🏻 I'm encountering a very strange issue. When I try to list my keys using c.env.<binding>.list(), I can see the keys listed in the terminal as expected. However, when I attempt to list the keys directly from the terminal, the namespace appears completely empty—no keys are returned. I also checked the Cloudflare dashboard, and it's showing the same issue: the namespace is empty. Has anyone else experienced this? Any idea why this might be happening?
No description
No description
Walshy
Walshy4mo ago
Local vs prod You're running dev locally so all storage is local, it doesn't exist in prod -- this is so you can safely dev your app without impacting production data The command (and ofc the dash) show production data not local
Arvind
Arvind4mo ago
Ahh that makes sense! Pretty new to cloudflare so did not know that. Thank you! :)
thomasgauvin
thomasgauvin4mo ago
@Arvind you can pass the --local=true parameter to wrangler to access the local values as well! https://developers.cloudflare.com/workers/wrangler/commands/#list-4
Cloudflare Docs
Commands | Cloudflare Workers docs
Create, develop, and deploy your Cloudflare Workers with Wrangler commands.
Arvind
Arvind4mo ago
Oh perfect, thank you!
willin
willin4mo ago
kv read operations seeems weird. how to figure it out?
No description
No description
Chaika
Chaika4mo ago
There's not really a tied relation between Worker Requests and KV Requests if that's what you're confused about, KV can be used via the API directly and Workers can do up to 1,000 in-house requests to KV even on free afaik. As for discovering what specifically is using KV operations, I would guess it's a worker and would go over your workers using KV. The Cloudflare GraphQL API can you show how many operations are being done per namespace/scope you down to namespace: https://developers.cloudflare.com/analytics/graphql-api/getting-started/authentication/graphql-client-headers/ but not any closer/not to exact worker
willin
willin4mo ago
is there an example query schema?
willin
willin4mo ago
which one
No description
Cyb3r-Jak3
Cyb3r-Jak34mo ago
Neither. I forget the actual name but it is something like kvOperationsAdaptiveGroup
Chaika
Chaika4mo ago
{
viewer {
accounts(filter: {accountTag: "<AccctId>"}) {
kvOperationsAdaptiveGroups(filter: {date_gt: "2024-08-30", actionType: "read" }, limit: 100, orderBy: [ sum_requests_DESC ]) {
dimensions {
actionType
namespaceId
}
sum {
requests
}

}
}
}
}
{
viewer {
accounts(filter: {accountTag: "<AccctId>"}) {
kvOperationsAdaptiveGroups(filter: {date_gt: "2024-08-30", actionType: "read" }, limit: 100, orderBy: [ sum_requests_DESC ]) {
dimensions {
actionType
namespaceId
}
sum {
requests
}

}
}
}
}
something like that to see most requests by namespace
0x7d8
0x7d84mo ago
basically I want to have an integer in d1 be incremented on each request to a specific endpoint, would it be possible to use kv to temporarily store how much needs to be added and then add it on a schedule? if so would that globally work since kv is local on the machine to my knowledge?
a4amaan
a4amaan4mo ago
getting same issue
No description
birdfly
birdfly4mo ago
Hello I frequently encounter code 971 issues while using KV. Could you please clarify what specific limitation this refers to? How can I adjust to reduce the occurrence of this problem?​⬤
Want results from more Discord servers?
Add your server