e93b551d24ac6528048f89837f73c2249b8ad001
[kivitendo-erp.git] / SL / DB / Helper / Cache.pm
1 package SL::DB::Helper::Cache;
2
3 use strict;
4 use warnings;
5
6 use Carp;
7
8 use parent qw(Rose::DB::Cache);
9
10 sub prepare_db {
11   my ($self, $db, $entry) = @_;
12
13   if (!$entry->is_prepared) {
14     # if this a dummy kivitendo dbh, don't try to actually prepare this.
15     if ($db->type =~ /KIVITENDO_EMPTY/) {
16       return;
17     }
18
19     $entry->prepared(1);
20   }
21
22   if (!$db->dbh->ping) {
23     $db->dbh(undef);
24   }
25 }
26
27 1;
28
29 __END__
30
31 =head1 NAME
32
33 SL::DB::Helper::Cache - database handle caching for kivitendo
34
35 =head1 DESCRIPTION
36
37 This class provides database cache handling for kivitendo running
38 under FastCGI. It's based on Rose::DBx::Cache::Anywhere.
39
40 =head1 METHODS
41
42 =head2 prepare_db( I<rose_db>, I<entry> )
43
44 Overrides default method to always ping() dbh.