-
The answer is probably yes, but just to conform: is Bun thread-safe? Is it possible to use the same *bun.DB in multiple goroutines, like it's the norm for web apps (i.e. open the connection once, use it in different handlers)? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Bump in 2024 |
Beta Was this translation helpful? Give feedback.
-
@ivoras I'm not one of the maintainers, but I have spent a fair amount of time in the codebase and am using bun in a number of applications in production. I can confirm that a You can't use queries (e.g., the result of a |
Beta Was this translation helpful? Give feedback.
@ivoras I'm not one of the maintainers, but I have spent a fair amount of time in the codebase and am using bun in a number of applications in production. I can confirm that a
*bun.DB
instance can be used concurrently. A*bun.DB
is mostly a light wrapper around asql.DB
, which maintains a connection pool and is also safe for concurrent use.You can't use queries (e.g., the result of a
db.NewSelect()
ordb.NewInsert()
) concurrently, though.