line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Connection::Memcached; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1078
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '2.01'; # VERSION |
6
|
|
|
|
|
|
|
# ABSTRACT: a memcached connection plugin for mtpolicyd |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Mail::MtPolicyd::Connection'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
4965
|
use Cache::Memcached; |
|
1
|
|
|
|
|
56336
|
|
|
1
|
|
|
|
|
204
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'servers' => ( is => 'ro', isa => 'Str', default => '127.0.0.1:11211' ); |
14
|
|
|
|
|
|
|
has '_servers' => ( |
15
|
|
|
|
|
|
|
is => 'ro', isa => 'ArrayRef[Str]', lazy => 1, |
16
|
|
|
|
|
|
|
default => sub { |
17
|
|
|
|
|
|
|
my $self = shift; |
18
|
|
|
|
|
|
|
return [ split(/\s*,\s*/, $self->servers) ]; |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has 'debug' => ( is => 'ro', isa => 'Bool', default => 0 ); |
23
|
|
|
|
|
|
|
has 'namespace' => ( is => 'ro', isa => 'Str', default => ''); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _create_handle { |
26
|
0
|
|
|
0
|
|
|
my $self = shift; |
27
|
0
|
|
|
|
|
|
return Cache::Memcached->new( { |
28
|
|
|
|
|
|
|
'servers' => $self->_servers, |
29
|
|
|
|
|
|
|
'debug' => $self->debug, |
30
|
|
|
|
|
|
|
'namespace' => $self->namespace, |
31
|
|
|
|
|
|
|
} ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'handle' => ( |
35
|
|
|
|
|
|
|
is => 'rw', isa => 'Cache::Memcached', lazy => 1, |
36
|
|
|
|
|
|
|
default => sub { |
37
|
|
|
|
|
|
|
my $self = shift; |
38
|
|
|
|
|
|
|
$self->_create_handle |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub reconnect { |
43
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
44
|
0
|
|
|
|
|
|
$self->handle( $self->_create_handle ); |
45
|
0
|
|
|
|
|
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub shutdown { |
49
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
$self->handle->disconnect_all; |
51
|
0
|
|
|
|
|
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=pod |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=encoding UTF-8 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Mail::MtPolicyd::Connection::Memcached - a memcached connection plugin for mtpolicyd |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 VERSION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
version 2.01 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
<Connection memcached> |
73
|
|
|
|
|
|
|
module = "Memcached" |
74
|
|
|
|
|
|
|
servers = "127.0.0.1:11211" |
75
|
|
|
|
|
|
|
# namespace = "mt-" |
76
|
|
|
|
|
|
|
</Connection> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 PARAMETERS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item servers (default: 127.0.0.1:11211) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Comma seperated list for memcached servers to connect. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item debug (default: 0) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Enable to debug memcached connection. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item namespace (default: '') |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Set a prefix used for all keys of this connection. |
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 |