line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package ResourcePool::Resource::Redis; |
4
|
2
|
|
|
2
|
|
30553
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
70
|
|
5
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
6
|
2
|
|
|
2
|
|
2224
|
use Redis; |
|
2
|
|
|
|
|
181473
|
|
|
2
|
|
|
|
|
199
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 1.0; |
9
|
2
|
|
|
2
|
|
29
|
use base qw(ResourcePool::Resource); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1471
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
2
|
|
|
2
|
1
|
161
|
my $proto = shift; |
13
|
2
|
|
33
|
|
|
13
|
my $class = ref($proto) || $proto; |
14
|
2
|
|
|
|
|
21
|
my $self = $class->SUPER::new(); |
15
|
2
|
|
|
|
|
30
|
my %args = @_; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
4
|
$self->{'redis'} = eval {Redis->new(%args)}; |
|
2
|
|
|
|
|
12
|
|
18
|
2
|
50
|
|
|
|
36
|
warn $@ if $@; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
5
|
bless($self, $class); |
21
|
2
|
|
|
|
|
7
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub close { |
25
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
26
|
0
|
|
|
|
|
0
|
eval {$self->{'redis'}->quit()}; |
|
0
|
|
|
|
|
0
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub precheck { |
30
|
1
|
|
|
1
|
1
|
13
|
my ($self) = @_; |
31
|
1
|
|
50
|
|
|
4
|
my $rc = uc($self->{'redis'}->ping() || '') eq 'PONG'; |
32
|
1
|
50
|
|
|
|
10
|
$rc or $self->close(); |
33
|
1
|
|
|
|
|
3
|
return $rc; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub postcheck { |
37
|
1
|
|
|
1
|
1
|
310
|
return 1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_plain_resource { |
41
|
2
|
|
|
2
|
1
|
769
|
my ($self) = @_; |
42
|
2
|
|
|
|
|
6
|
return $self->{'redis'}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub DESTROY { |
46
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
47
|
0
|
|
|
|
|
|
$self->close(); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |