projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Wiedervorlage aus Angebot/Auftrag: Betreff aus Vorgangsbezeichnung vorbelegen
[kivitendo-erp.git]
/
SL
/
DBConnect
/
Cache.pm
diff --git
a/SL/DBConnect/Cache.pm
b/SL/DBConnect/Cache.pm
index
b04a5b4
..
c133e8a
100644
(file)
--- a/
SL/DBConnect/Cache.pm
+++ b/
SL/DBConnect/Cache.pm
@@
-35,14
+35,23
@@
sub reset {
$dbh;
}
$dbh;
}
+sub reset_all {
+ $_->{AutoCommit} || $_->rollback for values %cache;
+}
+
sub clear {
%cache = ();
}
sub clear {
%cache = ();
}
+sub disconnect_all_and_clear {
+ $_->disconnect for values %cache;
+ %cache = ();
+}
+
sub _args2str {
my (@args) = @_;
sub _args2str {
my (@args) = @_;
- my ($dbconnect, $dbuser, $dbpasswd, $options) = @_;
+ my ($dbconnect, $dbuser, $dbpasswd, $options
, $initial_sql
) = @_;
$dbconnect //= '';
$dbuser //= '';
$dbpasswd //= '';
$dbconnect //= '';
$dbuser //= '';
$dbpasswd //= '';
@@
-52,7
+61,7
@@
sub _args2str {
map { $_ => $options->{$_} }
sort keys %$options; # deterministic order
map { $_ => $options->{$_} }
sort keys %$options; # deterministic order
- join ';', apply {
s/([;\\])/\\$1/g } $dbconnect, $dbuser, $dbpasswd, $options_str
;
+ join ';', apply {
$_ //= ''; s/([;\\])/\\$1/g } $dbconnect, $dbuser, $dbpasswd, $options_str, $initial_sql
;
}
1;
}
1;
@@
-67,26
+76,26
@@
SL::DBConnect::Cache - cached database handle pool
=head1 SYNOPSIS
=head1 SYNOPSIS
- use SL::
S
BConnect::Cache;
+ use SL::
D
BConnect::Cache;
- my $dbh = SL::DBConnct::Cache->get(@args);
- SL::DBConnct::Cache->store($dbh, @args);
+ my $dbh = SL::DBConn
e
ct::Cache->get(@args);
+ SL::DBConn
e
ct::Cache->store($dbh, @args);
# reset a cached handle
# reset a cached handle
- SL::DBConnct::Cache->reset($dbh);
+ SL::DBConn
e
ct::Cache->reset($dbh);
# close a cached handle and forget it
# close a cached handle and forget it
- SL::DBConnct::Cache->close($dbh);
+ SL::DBConn
e
ct::Cache->close($dbh);
- SL::DBConnct::Cache->clear($dbh);
+ SL::DBConn
e
ct::Cache->clear($dbh);
=head1 DESCRIPTION
=head1 DESCRIPTION
-Implement
e
s a managed cache for DB connection handles.
+Implements a managed cache for DB connection handles.
The same would be possible with C<< DBI->connect_cached >>, but in that case,
The same would be possible with C<< DBI->connect_cached >>, but in that case,
-we would have no control ver the cache.
+we would have no control
o
ver the cache.
=head1 METHODS
=head1 METHODS
@@
-106,7
+115,7
@@
Rollback the connection specified by C<ARGS>.
=item * C<clear>
=item * C<clear>
-Emties the cache. If handles are not referenced otherwise, they will get
+Em
p
ties the cache. If handles are not referenced otherwise, they will get
dropped and closed.
=back
dropped and closed.
=back