connect_cached (NEW )
$dbh = DBI->connect_cached($data_source, $username, $password) || die $DBI::errstr; $dbh = DBI->connect_cached($data_source, $username, $password, \%attr) || die $DBI::errstr;
connect_cached
is like connect, except that the database handle
returned is also stored in a hash associated with the given
parameters. If another call is made to
connect_cached
with the same parameter values,
then the corresponding cached $dbh
will be
returned if it is still valid. The cached database handle is replaced
with a new connection if it has been disconnected or if the
ping
method fails.
Note that the behavior of this method differs in several respects
from the behavior of persistent connections implemented by
Apache::DBI
.
Caching can be useful in some applications, but it can also cause problems and should be used with care. The exact behavior of this method is liable to change, so if you intend to use it in any production applications you should discuss your needs on the dbi-users mailing list.
The cache can be accessed (and cleared) via the
CachedKids
attribute.