[Dbix-class] Caching connections

Dan Horne dan.horne at redbone.co.nz
Sun Apr 30 22:14:31 CEST 2006


Behalf Of Tim Sweetman



> I presume that this is using session affinity to tie the administrative
users to a 

> particular process, so they pick up the same DB handle again.



User's aren't specifically tied to a process, but they are tied to the same
database handle based on who they are. All invocations of DBI's
connect_cached method with the same parameters will result in the same
cached connection being used. I add an extra attribute to the method call,
(username => $username) to ensure that back-end users who require
transactional safety don't share connections. Front-end users don't have a
username, so they get to share the same connection

 

> Caching connections can be useful in some applications, but it can also
cause problems, 

> such as too many connections, and so should be used with care

 

Too true! But there are a limited number of backend users, so even if they
all happened to log in at once, I may have 10 or so database connections.
This many concurrent admin users would be rare. Plus the persistent Perl
process dies every five minutes or so, so we don't tend to have any unused
connections hanging around.

 

Dan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/dbix-class/attachments/20060501/e189e127/attachment-0001.htm 


More information about the Dbix-class mailing list