From: MoonWolf Date: 2004-10-26T23:07:23+09:00 Subject: Re: [ANN] Apache::DBI 0.0.20041025b Brian Candler wrote: > I'm guessing now. Does your module keep a separate database instance for > each unique value of the DBI string? Or each unique combination of all the > arguments inside DBI.connect(...) ? Apache::DBI has each unique combination of all the arguments. > In other words, does it do something like > > $dbh ||= {} > $dbh['dbi:Pg:bar'] ||= DBI.connect('dbi:Pg:bar') > > Help me out here :-) I'm just trying to understand what it's doing, so I can > see whether I can make use of it. > > If my guess is correct, then perhaps the pattern can be abstracted: e.g. > > dbh = Persistent[DBI, :connect, 'dbi:Pg:bar', ...] > > and the implementation would be: > > module Persistent > @things = {} > def self.[](*args) > @things[args] ||= args[0].send(*args[1..-1]) > end > end I think that it is necessary to take into consideration that it is also peculiar to DBI, such as disconnet. in future release, disconnected DBI instance(at DBI exception) is automatically delete from Apache::DBI cache.