From: Moritz Bunkus Date: Wed, 3 Apr 2019 15:14:20 +0000 (+0200) Subject: SL::DB::Cache nach SL::DB::Helper::Cache verschoben X-Git-Tag: release-3.5.4~75^2~2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=b9d5cb7b49b3394142b257cd0186652e91cb3b5f;p=kivitendo-erp.git SL::DB::Cache nach SL::DB::Helper::Cache verschoben Da es sich nicht um eine Mapping-Klasse einer Tabelle handelt, sollte sie nicht direkt innerhalb von SL::DB liegen. --- diff --git a/SL/DB.pm b/SL/DB.pm index d098302ad..c678ed14f 100644 --- a/SL/DB.pm +++ b/SL/DB.pm @@ -6,12 +6,12 @@ use Carp; use Data::Dumper; use English qw(-no_match_vars); use Rose::DB; -use SL::DB::Cache; +use SL::DB::Helper::Cache; use Scalar::Util qw(blessed); use base qw(Rose::DB); -__PACKAGE__->db_cache_class('SL::DB::Cache'); +__PACKAGE__->db_cache_class('SL::DB::Helper::Cache'); __PACKAGE__->use_private_registry; my (%_db_registered); diff --git a/SL/DB/Cache.pm b/SL/DB/Cache.pm deleted file mode 100644 index a0e8d7845..000000000 --- a/SL/DB/Cache.pm +++ /dev/null @@ -1,44 +0,0 @@ -package SL::DB::Cache; - -use strict; -use warnings; - -use Carp; - -use parent qw(Rose::DB::Cache); - -sub prepare_db { - my ($self, $db, $entry) = @_; - - if (!$entry->is_prepared) { - # if this a dummy kivitendo dbh, don't try to actually prepare this. - if ($db->type =~ /KIVITENDO_EMPTY/) { - return; - } - - $entry->prepared(1); - } - - if (!$db->dbh->ping) { - $db->dbh(undef); - } -} - -1; - -__END__ - -=head1 NAME - -SL::DB::Cache - database handle caching for kivitendo - -=head1 DESCRIPTION - -This class provides database cache handling for kivitendo running -under FastCGI. It's based on Rose::DBx::Cache::Anywhere. - -=head1 METHODS - -=head2 prepare_db( I, I ) - -Overrides default method to always ping() dbh. diff --git a/SL/DB/Helper/Cache.pm b/SL/DB/Helper/Cache.pm new file mode 100644 index 000000000..e93b551d2 --- /dev/null +++ b/SL/DB/Helper/Cache.pm @@ -0,0 +1,44 @@ +package SL::DB::Helper::Cache; + +use strict; +use warnings; + +use Carp; + +use parent qw(Rose::DB::Cache); + +sub prepare_db { + my ($self, $db, $entry) = @_; + + if (!$entry->is_prepared) { + # if this a dummy kivitendo dbh, don't try to actually prepare this. + if ($db->type =~ /KIVITENDO_EMPTY/) { + return; + } + + $entry->prepared(1); + } + + if (!$db->dbh->ping) { + $db->dbh(undef); + } +} + +1; + +__END__ + +=head1 NAME + +SL::DB::Helper::Cache - database handle caching for kivitendo + +=head1 DESCRIPTION + +This class provides database cache handling for kivitendo running +under FastCGI. It's based on Rose::DBx::Cache::Anywhere. + +=head1 METHODS + +=head2 prepare_db( I, I ) + +Overrides default method to always ping() dbh.