line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Connection::Redis; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1868
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '2.02'; # VERSION |
6
|
|
|
|
|
|
|
# ABSTRACT: a mtpolicy connection for redis databases |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Mail::MtPolicyd::Connection'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
8758
|
use Redis; |
|
1
|
|
|
|
|
15160
|
|
|
1
|
|
|
|
|
175
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'server' => ( is => 'ro', isa => 'Str', default => '127.0.0.1:6379' ); |
14
|
|
|
|
|
|
|
has 'debug' => ( is => 'ro', isa => 'Bool', default => 0 ); |
15
|
|
|
|
|
|
|
has 'password' => ( is => 'ro', isa => 'Maybe[Str]' ); |
16
|
|
|
|
|
|
|
has 'db' => ( is => 'ro', isa => 'Int', default => 0 ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _create_handle { |
19
|
0
|
|
|
0
|
|
|
my $self = shift; |
20
|
0
|
0
|
|
|
|
|
my $redis = Redis->new( |
21
|
|
|
|
|
|
|
'server' => $self->server, |
22
|
|
|
|
|
|
|
'debug' => $self->debug, |
23
|
|
|
|
|
|
|
defined $self->password ? ( 'password' => $self->password ) : (), |
24
|
|
|
|
|
|
|
); |
25
|
0
|
|
|
|
|
|
$redis->select( $self->db ); |
26
|
0
|
|
|
|
|
|
return $redis; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'handle' => ( |
30
|
|
|
|
|
|
|
is => 'rw', isa => 'Redis', lazy => 1, |
31
|
|
|
|
|
|
|
default => sub { |
32
|
|
|
|
|
|
|
my $self = shift; |
33
|
|
|
|
|
|
|
return $self->_create_handle; |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub reconnect { |
38
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
39
|
0
|
|
|
|
|
|
$self->handle( $self->_create_handle ); |
40
|
0
|
|
|
|
|
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub shutdown { |
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
45
|
0
|
|
|
|
|
|
$self->handle->wait_all_responses; |
46
|
0
|
|
|
|
|
|
$self->handle->quit; |
47
|
0
|
|
|
|
|
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=pod |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=encoding UTF-8 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Mail::MtPolicyd::Connection::Redis - a mtpolicy connection for redis databases |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 VERSION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
version 2.02 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
<Connection redis> |
69
|
|
|
|
|
|
|
server = "127.0.0.1:6379" |
70
|
|
|
|
|
|
|
db = 0 |
71
|
|
|
|
|
|
|
# password = "secret" |
72
|
|
|
|
|
|
|
</Connection> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 PARAMETERS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=over |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item server (default: 127.0.0.1:6379) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
The redis server to connect. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item debug (default: 0) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Set to 1 to enable debugging of redis connection. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item password (default: undef) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Set password if required for redis connection. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item db (default: 0) |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Select a redis database to use. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This is free software, licensed under: |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |