Hi -
I’m experimenting with Workers KV on the free plan.
My code is using a very simple prefix match list operation:
// Query Cloudflare Worker KV namespace for prefix match
const metadataValues = await kv_registrations.list({
prefix: "uid:" + uid
});
I don’t need to retrieve the key value because everything I need is returned in the metadata.
There are currently less than 10 keys in my namespace.
Functionally it works great, although I’m less impressed with response times.
The first query response time is around 750ms.
Subsequent responses are then very fast around 35 - 40ms.
But if I constantly refresh the query, I noticed that after exactly 30 seconds from the first query, the response time spikes back up to 750ms.
Subsequent queries are then very fast again for exactly 30 more seconds, then again they spike back up to 750ms.
This pattern repeats constantly. I’m guessing the local cache is being invalidated every 30 seconds and reloaded from the core.
I noticed that the cacheTTL parameter is available for get operations (but I’m using list), and it’s set to 60 seconds by default.
Does anyone know why I see these spikes in response times every 30 seconds?
And whether there is any solution/workaround for list queries?
Thanks in advance