line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Cache::Memcached::Fast; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
489005
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
88
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
209
|
|
5
|
2
|
|
|
2
|
|
12
|
use base 'Class::Data::Inheritable'; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
2136
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION='0.14'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1009349
|
use Cache::Memcached::Fast; |
|
2
|
|
|
|
|
2335406
|
|
|
2
|
|
|
|
|
392
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('cache'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head2 EXTENDED METHODS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head3 setup |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub setup { |
21
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $params = {}; |
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
if ( $self->config->{cache} ) { |
26
|
0
|
|
|
|
|
|
$params = { %{ $self->config->{cache} } }; |
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if( ref $params->{servers} ne 'ARRAY' ){ |
30
|
0
|
|
|
|
|
|
$params->{servers} = [$params->{servers}]; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$self->cache( Cache::Memcached::Fast->new($params) ); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
return $self->next::method(@_); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Catalyst::Plugin::Cache::Memcached::Fast - Catalyst Plugin for Cache::Memcached::Fast |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use Catalyst qw[Cache::Memcached::Fast]; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
MyApp->config( |
51
|
|
|
|
|
|
|
cache => { |
52
|
|
|
|
|
|
|
servers => [ |
53
|
|
|
|
|
|
|
'127.0.0.1:11211', |
54
|
|
|
|
|
|
|
'127.0.0.1:11212', |
55
|
|
|
|
|
|
|
], |
56
|
|
|
|
|
|
|
namespace => 'MyApp:', |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
my $data; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
unless ( $data = $c->cache->get('data') ) { |
62
|
|
|
|
|
|
|
$data = $c->model('MyApp::MyData')->search(); |
63
|
|
|
|
|
|
|
$c->cache->set( 'data', $data ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$c->response->body($data); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 DESCRIPTION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Extends base class with a distributed cache. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=over 4 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item cache |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns an instance of C<Cache::Memcached::Fast> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=back |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SEE ALSO |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
L<Cache::Memcached::Fast>, L<Catalyst>. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
S<Vasiliy Voloshin>, C<< <vasiliy.voloshin at gmail.com> >> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 LICENSE |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This library is free software . You can redistribute it and/or modify |
94
|
|
|
|
|
|
|
it under the same terms as perl itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |