Closed joelgallant closed 4 years ago
If you only want one connection to the database, why use a pool at all rather than just a Mutex<SqliteConnection>
?
Specifically, I use tokio-diesel (which has an impl for r2d2), and I only have one case in my application (can't say very much about it) which is :memory:
, and by configuration could be in-memory or not. I wouldn't want to write two implementations of every database call just to handle that, so my solution is to use r2d2 with only one persistent "connection" to :memory:
. Maybe there's a better way?
Given that this seems like a pretty niche use case and you can use the existing configuration to support it, I don't really think it's necessary to introduce a "compound" configuration option for the first time.
Because of things like tokio-diesel, sometimes it makes sense to use r2d2 with an in-memory database. It was very confusing to see r2d2 handle things totally fine until 30 minutes (max lifetime), until realizing what was actually happening.
This could very well be a documentation item too, I have no real opinion. But somewhere greppable for
:memory:
/sqlite would be awesome.