On Oct 2, 2009, at 9:30 AM, Kurt Hansen wrote:
I'm wondering what techniques folks are using to get persistent database connections other than Apache::DBI.
I plan to release a new module, DBIx::Connection, on Monday. It's based on the connection caching stuff in DBIx::Class, and also has some nice transaction management stuff, so you might want to [check it out](http://github.com/theory/dbix-connection/).
Right now, following DBIx::Class's precedent, it disables Apache::DBI when it connects to the database. That may or may not be something I want to revisit, but since DBIx::Connection does its own caching, I rather suspect it's best not to also cache with Apache::DBI.
If you use it, you might also want "install your own cleanup handler to issue a rollback on all open database handles at the end of every web request," as Perrin says. Bricolage does that with its use of connect_cached(), and that works great. It's safe to create a connection on startup with DBIx::Connection though, as it is careful not to cache across fork or thread boundaries.
Critiques welcome, BTW. I'll likely blog about it next week, too. Best, David