Revision ffa9f969
Von Sven Schöling vor mehr als 9 Jahren hinzugefügt
SL/DBConnect.pm | ||
---|---|---|
4 | 4 |
|
5 | 5 |
use DBI; |
6 | 6 |
use SL::DB; |
7 |
use SL::DBConnect::Cache; |
|
7 | 8 |
|
8 | 9 |
my %dateformat_to_datestyle = ( |
9 | 10 |
'yy-mm-dd' => 'ISO', |
... | ... | |
33 | 34 |
sub connect { |
34 | 35 |
my ($self, @args) = @_; |
35 | 36 |
|
37 |
if (my $cached_dbh = SL::DBConnect::Cache->get(@args)) { |
|
38 |
return $cached_dbh; |
|
39 |
} |
|
40 |
|
|
36 | 41 |
my $dbh = $self->_connect(@args); |
37 | 42 |
return undef if !$dbh; |
38 | 43 |
|
39 | 44 |
my $initial_sql = $self->get_initial_sql; |
40 | 45 |
$dbh->do($initial_sql) if $initial_sql; |
41 | 46 |
|
47 |
SL::DBConnect::Cache->store($dbh, @args); |
|
48 |
|
|
42 | 49 |
return $dbh; |
43 | 50 |
} |
44 | 51 |
|
Auch abrufbar als: Unified diff
Dispatcher: Client DB Handles cachen.
Spart etwa ein Drittel an Requestoverhead, von 27ms auf 17ms.