hi is it possible to save a d1 prepared statement in a global variable or something when my worker i
hi is it possible to save a d1 prepared statement in a global variable or something when my worker is initializing, so I can reuse it across multiple invocations? currently, I've got the following:
so unless there's some sort of caching under the hood, I guess it'd have to parse the query every time my handler gets called, which I want to avoid. Mainly, I'm not sure how to access the
edit: actually i'm gonna introduce a db abstraction layer which caches prepared stmts in global variables and if there's no prepared stmt cached then it creates a fresh one. from reading online, it seems like global variables' consistency guarantees would b fine for this sort of use-case
so unless there's some sort of caching under the hood, I guess it'd have to parse the query every time my handler gets called, which I want to avoid. Mainly, I'm not sure how to access the
c.env.DB object from outside the handle function of an endpointedit: actually i'm gonna introduce a db abstraction layer which caches prepared stmts in global variables and if there's no prepared stmt cached then it creates a fresh one. from reading online, it seems like global variables' consistency guarantees would b fine for this sort of use-case
