line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Async::Memcached; |
2
|
|
|
|
|
|
|
# ABSTRACT: IO::Async support for the memcached protocol |
3
|
1
|
|
|
1
|
|
12580
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
59
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
53
|
|
5
|
1
|
|
|
1
|
|
903
|
use parent qw(Protocol::Memcached Mixin::Event::Dispatch); |
|
1
|
|
|
|
|
379
|
|
|
1
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Net::Async::Memcached - basic L support for memcached |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
version 0.001 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use strict; |
20
|
|
|
|
|
|
|
use warnings; |
21
|
|
|
|
|
|
|
use IO::Async::Loop; |
22
|
|
|
|
|
|
|
use Net::Async::Memcached::Client; |
23
|
|
|
|
|
|
|
my $loop = IO::Async::Loop->new; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Will begin connection immediately on instantiation |
26
|
|
|
|
|
|
|
$mc = Net::Async::Memcached::Client->new( |
27
|
|
|
|
|
|
|
host => 'localhost', # this is the default |
28
|
|
|
|
|
|
|
loop => $loop, |
29
|
|
|
|
|
|
|
on_connected => sub { |
30
|
|
|
|
|
|
|
my $mc = shift; |
31
|
|
|
|
|
|
|
my ($k, $v) = qw(hello world); |
32
|
|
|
|
|
|
|
$mc->set( |
33
|
|
|
|
|
|
|
$k => $v, |
34
|
|
|
|
|
|
|
on_complete => sub { |
35
|
|
|
|
|
|
|
$mc->get( |
36
|
|
|
|
|
|
|
$k, |
37
|
|
|
|
|
|
|
on_complete => sub { |
38
|
|
|
|
|
|
|
my %args = @_; |
39
|
|
|
|
|
|
|
print "Value stored was " . $args{value} . "\n"; |
40
|
|
|
|
|
|
|
$loop->later(sub { $loop->loop_stop }); |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
on_error => sub { die "Failed because of @_\n" } |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Provides basic memcached support - see L for a list of available |
52
|
|
|
|
|
|
|
methods. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This is the parent class used by L and |
55
|
|
|
|
|
|
|
L. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 stream |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Accessor for internal L object representing the underlying memcached |
64
|
|
|
|
|
|
|
transport. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
0
|
1
|
|
sub stream { shift->{stream} } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 write |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Proxies a L C request to the underlying transport. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub write { |
77
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
78
|
0
|
|
|
|
|
|
return $self->stream->write(@_); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# XXX - should really provide some form of auto-reconnection perhaps? thinking along the lines of this in the client: |
81
|
|
|
|
|
|
|
# if(my $stream = $self->stream) { |
82
|
|
|
|
|
|
|
# $self->stream->write(@_); |
83
|
|
|
|
|
|
|
# } else { |
84
|
|
|
|
|
|
|
# $self->connect( |
85
|
|
|
|
|
|
|
# on_connected => sub { |
86
|
|
|
|
|
|
|
# my $self = shift; |
87
|
|
|
|
|
|
|
# $self->stream->write(@_); |
88
|
|
|
|
|
|
|
# } |
89
|
|
|
|
|
|
|
# ); |
90
|
|
|
|
|
|
|
# } |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 service |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Accessor for the C information - this is the port or service name we will attempt to |
96
|
|
|
|
|
|
|
connect to or listen on. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
0
|
1
|
|
sub service { shift->{service} } |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |