Are those read times done immediately after writing? Keen in mind KV takes 60 seconds to be globally
Are those read times done immediately after writing? Keen in mind KV takes 60 seconds to be globally replicated
const cached = await KV.get(key, { type: 'json', cacheTtl: 1800 })
if (cached) return cached
await KV.put(key, JSON.stringify(value), { expirationTtl: 1800 })cacheTtl and expirationTtl set to 1800 (30 min), the D1 analytics show hundreds of reads over 48 hours, even though the value rarely changes and should be served from cache most of the time. For example I expected around 96 calls but i'm getting like ~500.remove namespace: 'namespace has associated scripts: pages-worker--2406846-production 


getWithMetadata function, what are the possible return values for the cacheStatus property. I don't see any info on it here: https://developers.cloudflare.com/kv/api/read-key-value-pairs/#getwithmetadata-methodconst cached = await KV.get(key, { type: 'json', cacheTtl: 1800 })
if (cached) return cached
await KV.put(key, JSON.stringify(value), { expirationTtl: 1800 })async function putKeys(env: Env, pairs: Array<Record<string, string>>): Promise<Response> {
for (const pair of pairs) {
var lastE = null;
for (let i = 0; i < retries; i++) {
try {
await env.KV_NS.put(pair["key"], pair["value"], {
metadata: {
version: "v1",
timestamp: ((Date.now() / 1000) | 0)
}
});
console.log({"message": `Successful to sync key ${pair["key"]}`});
break;
} catch(e) {
lastE = e;
}
}
if (lastE != null) {
console.error({"message": `Failed to sync key ${pair["key"]}`, error: lastE});
}
}
console.log({"message": `Successful synced ${pairs.length} pairs`});
return new Response(null, {});
}const client = new Cloudflare({
apiToken: CLOUDFLARE_API_TOKEN
});
console.log("List all Regional Services regions available for use by this account.");
for await (const regionListResponse of client.addressing.regionalHostnames.regions.list({
account_id: ACCOUNT_ID,
})) {
console.log(regionListResponse);
}
// Got `error: 403 {"result":null,"success":false,"errors":[{"code":1002,"message":"forbidden"}],"messages":[]}`
console.log("List all Regional Hostnames within a zone.");
for await (const regionalHostnameListResponse of client.addressing.regionalHostnames.list({
zone_id: ZONE_ID
})) {
console.log(regionalHostnameListResponse);
}