Im needing some help with kv fetching. I
Im needing some help with kv fetching. I am using BetterKV for fetching a rarely-updated value (but pretty important to have latest value with semi-low latency). This value is actually stored in my db and passed into kv and cached for performance (i believe kv w/ caching is faster for global users but I need to still actually do performance testing). Ideally, I want the
cacheTtl
and kvCacheTtl
to be high for low latency, but I dont want to have to wait for kvCacheTtl
to expire to fetch the updated value if needed. Am I thinking about this right and do I have to just bite the bullet and have low cache ttl values?6 Replies
What are you building here (that could help get a pulse on the performance needed and the inconsistency tolerance)?
I want to store the an api key and some associated data in kv so I can quickly validate the key and fetch the other data in my "proxy worker"
so the inconsistency tolerance needs to be decent so if I was to remove an api key I would no longer validate any requests
but then I need caching just to keep latency as low as possible
I'm also really curious about this. I would like to be able to clear all edge cache for a given KV key when that key is updated
KV doesn't provide this type of consistent storage. Have you considered using durable objects or D1 instead?
I'm actually using KV as a cache for "heavy" db calls - not sure if that's a good use
anyway for my use case I guess I can get away with setting a lower ttl, and also fetching D1 directly only when an immediate response is necessary
Using it as a cache for heavy db calls can work if you can tolerate the minimum ttl of 60 seconds for cache, many folks use it for that