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
thomasgauvin
thomasgauvin4mo ago
What are you building here (that could help get a pulse on the performance needed and the inconsistency tolerance)?
King Kazu
King Kazu4mo ago
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
thipperz
thipperz3mo ago
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
thomasgauvin
thomasgauvin3mo ago
KV doesn't provide this type of consistent storage. Have you considered using durable objects or D1 instead?
thipperz
thipperz3mo ago
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
thomasgauvin
thomasgauvin3mo ago
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
Want results from more Discord servers?
Add your server