line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Auth::Kokolores::Plugin::MemcachedConnection; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1714
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
4560
|
use Cache::Memcached; |
|
1
|
|
|
|
|
58433
|
|
|
1
|
|
|
|
|
50
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: kokolores plugin to configure a memcached connection |
7
|
|
|
|
|
|
|
our $VERSION = '1.01'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
extends 'Auth::Kokolores::Plugin'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Auth::Kokolores::ConnectionPool; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
216
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'servers' => ( is => 'ro', isa => 'Str', default => '127.0.0.1:11211'); |
15
|
|
|
|
|
|
|
has 'namespace' => ( is => 'ro', isa => 'Str', default => 'auth-'); |
16
|
|
|
|
|
|
|
has 'handle' => ( is => 'rw', isa => 'Str', default => 'memcached' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has _servers => ( |
19
|
|
|
|
|
|
|
is => 'ro', isa => 'ArrayRef[Str]', lazy => 1, |
20
|
|
|
|
|
|
|
default => sub { |
21
|
|
|
|
|
|
|
return [ split( /\s*,\s*/, shift->servers ) ]; |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'memcached' => ( |
26
|
|
|
|
|
|
|
is => 'ro', isa => 'Cache::Memcached', |
27
|
|
|
|
|
|
|
lazy => 1, |
28
|
|
|
|
|
|
|
default => sub { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
$self->log(3, 'creating memcached connection to '.join(', ', @{$self->_servers}).'...'); |
31
|
|
|
|
|
|
|
return Cache::Memcached->new( { |
32
|
|
|
|
|
|
|
'servers' => $self->_servers, |
33
|
|
|
|
|
|
|
'debug' => 0, |
34
|
|
|
|
|
|
|
'namespace' => $self->namespace, |
35
|
|
|
|
|
|
|
} ); |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub child_init { |
40
|
0
|
|
|
0
|
0
|
|
my ( $self, $r ) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$self->log(3, 'registring memcached connection \''.$self->handle.'\'...'); |
43
|
0
|
|
|
|
|
|
Auth::Kokolores::ConnectionPool->add_handle( |
44
|
|
|
|
|
|
|
$self->handle => $self->memcached, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub shutdown { |
51
|
0
|
|
|
0
|
0
|
|
my ( $self, $r ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$self->log(3, 'unregistring memcached connection \''.$self->handle.'\'...'); |
54
|
0
|
|
|
|
|
|
Auth::Kokolores::ConnectionPool->clear_handle( $self->handle ); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=encoding UTF-8 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Auth::Kokolores::Plugin::MemcachedConnection - kokolores plugin to configure a memcached connection |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 VERSION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
version 1.01 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This plugin creates a connection to an memcached server for use |
78
|
|
|
|
|
|
|
by further plugins. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 EXAMPLE |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
<Plugin memcache> |
83
|
|
|
|
|
|
|
module = "MemcachedConnection" |
84
|
|
|
|
|
|
|
servers = "127.0.0.1:11211" |
85
|
|
|
|
|
|
|
namespace = "auth-" |
86
|
|
|
|
|
|
|
</Plugin> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 MODULE PARAMETERS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 servers (default: '127.0.0.1:112211') |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
A comma seperated list of servers. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 namespace (default: 'auth-') |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
A prefix to use for keys. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 handle (default: 'memcached') |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This string is used to register the memcached connection |
101
|
|
|
|
|
|
|
within the kokolores connection pool. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This software is Copyright (c) 2016 by Markus Benning <ich@markusbenning.de>. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is free software, licensed under: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |