|
1 |
package Rose::DBx::Cache::Anywhere;
|
|
2 |
use strict;
|
|
3 |
use warnings;
|
|
4 |
use Carp;
|
|
5 |
use base qw( Rose::DB::Cache );
|
|
6 |
|
|
7 |
=head1 NAME
|
|
8 |
|
|
9 |
Rose::DBx::Cache::Anywhere - get Apache::DBI behaviour without Apache
|
|
10 |
|
|
11 |
=head1 DESCRIPTION
|
|
12 |
|
|
13 |
This class is used by Rose::DBx::AutoReconnect.
|
|
14 |
The author uses
|
|
15 |
Rose::DB with Catalyst under both the Catalyst dev server and
|
|
16 |
FastCGI and found that the standard Rose::DB::Cache behaviour
|
|
17 |
did not work well with those environments.
|
|
18 |
|
|
19 |
=head1 METHODS
|
|
20 |
|
|
21 |
=head2 prepare_db( I<rose_db>, I<entry> )
|
|
22 |
|
|
23 |
Overrides default method to always ping() dbh if not running
|
|
24 |
under mod_perl.
|
|
25 |
|
|
26 |
=cut
|
|
27 |
|
|
28 |
sub prepare_db {
|
|
29 |
my ( $self, $db, $entry ) = @_;
|
|
30 |
|
|
31 |
if ( Rose::DB::Cache::MOD_PERL_1 || Rose::DB::Cache::MOD_PERL_2 ) {
|
|
32 |
return $self->SUPER::prepare_db( $db, $entry );
|
|
33 |
}
|
|
34 |
|
|
35 |
if ( !$entry->is_prepared ) {
|
|
36 |
if ( $entry->created_during_apache_startup ) {
|
|
37 |
if ( $db->has_dbh ) {
|
|
38 |
eval { $db->dbh->disconnect }; # will probably fail!
|
|
39 |
$db->dbh(undef);
|
|
40 |
}
|
|
41 |
|
|
42 |
$entry->created_during_apache_startup(0);
|
|
43 |
return;
|
|
44 |
}
|
|
45 |
|
|
46 |
# if this a dummy lx office dbh, don't try to actually prepare this.
|
|
47 |
if ($db->type =~ /LXOFFICE_EMPTY/) {
|
|
48 |
return;
|
|
49 |
}
|
|
50 |
|
|
51 |
$entry->prepared(1);
|
|
52 |
}
|
|
53 |
|
|
54 |
if ( !$db->dbh->ping ) {
|
|
55 |
$db->dbh(undef);
|
|
56 |
}
|
|
57 |
}
|
|
58 |
|
|
59 |
1;
|
|
60 |
|
|
61 |
__END__
|
|
62 |
|
|
63 |
=head1 AUTHOR
|
|
64 |
|
|
65 |
Peter Karman, C<< <karman at cpan.org> >>
|
|
66 |
|
|
67 |
=head1 BUGS
|
|
68 |
|
|
69 |
Please report any bugs or feature requests to
|
|
70 |
C<bug-rose-dbx-autoreconnect at rt.cpan.org>, or through the web interface at
|
|
71 |
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Rose-DBx-AutoReconnect>.
|
|
72 |
I will be notified, and then you'll automatically be notified of progress on
|
|
73 |
your bug as I make changes.
|
|
74 |
|
|
75 |
=head1 SUPPORT
|
|
76 |
|
|
77 |
You can find documentation for this module with the perldoc command.
|
|
78 |
|
|
79 |
perldoc Rose::DBx::AutoReconnect
|
|
80 |
|
|
81 |
You can also look for information at:
|
|
82 |
|
|
83 |
=over 4
|
|
84 |
|
|
85 |
=item * AnnoCPAN: Annotated CPAN documentation
|
|
86 |
|
|
87 |
L<http://annocpan.org/dist/Rose-DBx-AutoReconnect>
|
|
88 |
|
|
89 |
=item * CPAN Ratings
|
|
90 |
|
|
91 |
L<http://cpanratings.perl.org/d/Rose-DBx-AutoReconnect>
|
|
92 |
|
|
93 |
=item * RT: CPAN's request tracker
|
|
94 |
|
|
95 |
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Rose-DBx-AutoReconnect>
|
|
96 |
|
|
97 |
=item * Search CPAN
|
|
98 |
|
|
99 |
L<http://search.cpan.org/dist/Rose-DBx-AutoReconnect>
|
|
100 |
|
|
101 |
=back
|
|
102 |
|
|
103 |
=head1 ACKNOWLEDGEMENTS
|
|
104 |
|
|
105 |
The Minnesota Supercomputing Institute C<< http://www.msi.umn.edu/ >>
|
|
106 |
sponsored the development of this software.
|
|
107 |
|
|
108 |
=head1 COPYRIGHT
|
|
109 |
|
|
110 |
Copyright 2008 by the Regents of the University of Minnesota.
|
|
111 |
All rights reserved.
|
|
112 |
|
|
113 |
This program is free software; you can redistribute it and/or modify it
|
|
114 |
under the same terms as Perl itself.
|
|
115 |
|
|
116 |
=cut
|
Rose::DB Verbindungen automatisch neu verbinden wenn Sie im laufenden Betrieb kaputtgehen.