Thanks for the feedback @ItsWendell, like you mentioned, KV doesn't have cache purges but it's somet
Thanks for the feedback @ItsWendell, like you mentioned, KV doesn't have cache purges but it's something we're keeping our eyes on
wrangler dev) and trying to access some KV keys I've set using wrangler kv key put ... --local <key> <value> but my <kvnamespace>.get in my worker always returns null. I tried listing them from the worker too, and there's no keys at all. Listing them with "kv key list --local" tells me they are there. I can also read them with kv key get. Any suggestions on where I should start to dig to figure it out?npm run preview and in deploy, get some error: Error adding key-value pair: Error: Error adding key-value pair: ReferenceError: env is not definedexport const runtime = 'edge';
export const putKV = async (key, value) => {
try {
await env.KV_PREVIEW.put(key, value);
return;
} catch (error) {
throw new Error(Error adding key-value pair: ${error});
}
};
expirationTtl for the screenshots in KV is being set to 24 hours. My ideal would be to make the expiry much longer (e.g. 1 month), but with an implementation like an LRU cache where the TTL would reset whenever the value is read, so that only keys that haven’t been read for 1 month are evicted. Is there a way to accomplish something like that with KV, or is there another product that would be better suited for that kind of implementation? I did a search in discord and found kv, which suggests that KV’s expiration TTL isn’t the way to achieve this, but then because reading a value with a cacheTtl parameter resets any previous cacheTtl from a previous read, I thought there could be something there.Oh, that's first time I know that some part of KV is backed by DO.R2 is, not KV
But, from the document, I don't find any related to the cache time around the metadata in KV. I guess the cache policy is the same as value, right?For KV yea should be the same, but that document I linked was about R2, not KV
binding to is what you access in your env, ex: https://developers.cloudflare.com/kv/concepts/kv-bindings/#access-kv-from-workers
addEventListener('fetch',... (migrate to module workers is recommended) then it's a global var
wishlist_kv, the namewishlist_kv.get(key) gives me Cannot find name 'wishlist_kv'.Property 'put' does not exist on type '"wishlist_kv"'
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});
wrangler kv key put ... --local <key> <value>kv key getnpm run preview Error adding key-value pair: Error: Error adding key-value pair: ReferenceError: env is not definedError adding key-value pair: ${error}expirationTtlcacheTtlbindingaddEventListener('fetch',... wishlist_kvwishlist_kv.get(key)Cannot find name 'wishlist_kv'.Property 'put' does not exist on type '"wishlist_kv"'addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});