I m having a problem with my KV Cache I
I'm having a problem with my KV Cache. I get this error "this.kv.get is not a function" and I can't figure out why. Here is my implementation
I checked my NAMESPACE and when I console(this.kv) it matches what I setup in Cloudflare.
3 Replies
I figured this out but my Typescript is still wrong
I now access my Namespace from the
env
with the name passed as an environment variable like this
I have the env
typed with an interface and the Namespace doesn't play well with that approach.Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
Hey @MattD | WorkersKV Sorry, not sure how I missed your response. The issue is
CLOUDFLARE_KV_NAMESPACE
is a string that tells my application which namespace e.g. development-namespace or production-namespace and is defined at runtime not compile time. Cloudflare provides my namespace as defined by my wrangler config. So this is only a typescript issue now and I solved it like this.
Not sure if this is how other people are doing it, but it working for me right now.
Thanks for getting back with me!