line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Memcached::Client::Request; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
2
|
|
|
2
|
|
122
|
$Memcached::Client::Request::VERSION = '2.01'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Base class for Memcached::Client request drivers |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
72
|
|
8
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
90
|
|
9
|
2
|
|
|
2
|
|
12
|
use AnyEvent qw{}; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
36
|
|
10
|
2
|
|
|
2
|
|
12
|
use Memcached::Client::Log qw{DEBUG LOG}; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1508
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub generate { |
14
|
44
|
|
|
44
|
1
|
94
|
my ($class, $command) = @_; |
15
|
|
|
|
|
|
|
|
16
|
44
|
|
|
|
|
46
|
$class->log ("Class is %s, Command is %s", $class, $command) if DEBUG; |
17
|
|
|
|
|
|
|
return sub { |
18
|
0
|
|
|
0
|
|
|
my ($client, @args) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $request = bless {command => $command}, $class; |
21
|
0
|
|
|
|
|
|
$class->log ("Request is %s", $request) if DEBUG; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
$class->log ("Checking for condvar/callback") if DEBUG; |
24
|
0
|
0
|
0
|
|
|
|
if (ref $args[-1] eq 'AnyEvent::CondVar' or ref $args[-1] eq 'CODE') { |
25
|
0
|
|
|
|
|
|
$class->log ("Found condvar/callback") if DEBUG; |
26
|
0
|
|
|
|
|
|
$request->{cb} = pop @args; |
27
|
|
|
|
|
|
|
} else { |
28
|
0
|
|
|
|
|
|
$class->log ("Making own condvar") if DEBUG; |
29
|
0
|
|
|
|
|
|
$request->{cb} = AE::cv; |
30
|
0
|
|
|
|
|
|
$request->{wait} = 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$class->log ("Processing arguments: %s", \@args) if DEBUG; |
34
|
0
|
|
|
|
|
|
my @requests = $request->process (@args); |
35
|
0
|
0
|
|
|
|
|
if (@requests) { |
36
|
0
|
|
|
|
|
|
$class->log ("Submitting request(s)") if DEBUG; |
37
|
0
|
|
|
|
|
|
$client->__submit (@requests); |
38
|
|
|
|
|
|
|
} else { |
39
|
0
|
|
|
|
|
|
$request->result; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$class->log ("Checking whether to wait") if DEBUG; |
43
|
0
|
0
|
|
|
|
|
$request->{cb}->recv if ($request->{wait}); |
44
|
|
|
|
|
|
|
} |
45
|
44
|
|
|
|
|
272
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub log { |
49
|
0
|
|
|
0
|
1
|
|
my ($self, $format, @args) = @_; |
50
|
0
|
|
0
|
|
|
|
my $prefix = ref $self || $self; |
51
|
0
|
|
|
|
|
|
$prefix =~ s,Memcached::Client::Request::,Request/,; |
52
|
0
|
|
|
|
|
|
LOG ("$prefix> " . $format, @args); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub result { |
57
|
0
|
|
|
0
|
1
|
|
my ($self, @values) = @_; |
58
|
0
|
|
|
|
|
|
$self->log ("$self received result %s", \@values) if DEBUG; |
59
|
0
|
0
|
|
|
|
|
if (scalar @values) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$self->log ("We have a result") if DEBUG; |
61
|
|
|
|
|
|
|
} elsif (defined $self->{result}) { |
62
|
0
|
|
|
|
|
|
$self->log ("We have a stored result") if DEBUG; |
63
|
0
|
|
|
|
|
|
push @values, $self->{result}; |
64
|
|
|
|
|
|
|
} elsif (exists $self->{default}) { |
65
|
0
|
|
|
|
|
|
$self->log ("We have a default") if DEBUG; |
66
|
0
|
|
|
|
|
|
push @values, $self->{default}; |
67
|
|
|
|
|
|
|
} else { |
68
|
0
|
|
|
|
|
|
$self->log ("We have nothing to return") if DEBUG; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
0
|
|
|
|
|
unshift @values, $self->{key} if ($self->{sendkey}); |
71
|
0
|
|
|
|
|
|
$self->{cb}->(@values); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
package Memcached::Client::Request::Add; |
75
|
|
|
|
|
|
|
BEGIN { |
76
|
2
|
|
|
2
|
|
56
|
$Memcached::Client::Request::Add::VERSION = '2.01'; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
# ABSTRACT: Driver for Memcached::Client add-style requests |
79
|
|
|
|
|
|
|
|
80
|
2
|
|
|
2
|
|
14
|
use Memcached::Client::Log qw{DEBUG}; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
114
|
|
81
|
2
|
|
|
2
|
|
12
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
648
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub process { |
85
|
0
|
|
|
0
|
|
|
my ($self, $key, $value, $expiration) = @_; |
86
|
0
|
|
|
|
|
|
$self->{default} = 0; |
87
|
0
|
0
|
0
|
|
|
|
return () unless (defined $key and defined $value); |
88
|
0
|
|
0
|
|
|
|
$self->{expiration} = int ($expiration || 0); |
89
|
0
|
|
|
|
|
|
$self->{key} = $key; |
90
|
0
|
|
|
|
|
|
$self->{type} = "__add"; |
91
|
0
|
|
|
|
|
|
$self->{value} = $value; |
92
|
0
|
|
|
|
|
|
return $self; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
*Memcached::Client::add = Memcached::Client::Request::Add->generate ("add"); |
96
|
|
|
|
|
|
|
*Memcached::Client::append = Memcached::Client::Request::Add->generate ("append"); |
97
|
|
|
|
|
|
|
*Memcached::Client::prepend = Memcached::Client::Request::Add->generate ("prepend"); |
98
|
|
|
|
|
|
|
*Memcached::Client::replace = Memcached::Client::Request::Add->generate ("replace"); |
99
|
|
|
|
|
|
|
*Memcached::Client::set = Memcached::Client::Request::Add->generate ("set"); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
package Memcached::Client::Request::AddMulti; |
102
|
|
|
|
|
|
|
BEGIN { |
103
|
2
|
|
|
2
|
|
220
|
$Memcached::Client::Request::AddMulti::VERSION = '2.01'; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
# ABSTRACT: Driver for multiple Memcached::Client add-style requests |
106
|
|
|
|
|
|
|
|
107
|
2
|
|
|
2
|
|
14
|
use Memcached::Client::Log qw{DEBUG}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
122
|
|
108
|
2
|
|
|
2
|
|
12
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1262
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub process { |
112
|
0
|
|
|
0
|
|
|
my ($self, @requests) = @_; |
113
|
0
|
|
|
|
|
|
$self->{result} = {}; |
114
|
0
|
0
|
|
|
|
|
return () unless @requests; |
115
|
0
|
|
|
|
|
|
$self->{partial} = 0; |
116
|
0
|
|
|
|
|
|
return grep {$_} map { |
|
0
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
my $request = bless {command => $self->{command}, sendkey => 1}, "Memcached::Client::Request::Add"; |
118
|
|
|
|
|
|
|
$request->{cb} = sub { |
119
|
0
|
|
|
0
|
|
|
my ($key, $value) = @_; |
120
|
0
|
|
|
|
|
|
$self->log ("Noting that we received %s for %s", $value, $key) if DEBUG; |
121
|
0
|
0
|
|
|
|
|
$self->{result}->{$key} = $value if (defined $value); |
122
|
0
|
0
|
|
|
|
|
$self->result unless (--$self->{partial}); |
123
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
124
|
0
|
|
|
|
|
|
}; |
125
|
0
|
0
|
|
|
|
|
if ($request->process (@{$_})) { |
|
0
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
$self->{partial}++; |
127
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
128
|
0
|
|
|
|
|
|
$request; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} @requests; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
*Memcached::Client::add_multi = Memcached::Client::Request::AddMulti->generate ("add"); |
134
|
|
|
|
|
|
|
*Memcached::Client::append_multi = Memcached::Client::Request::AddMulti->generate ("append"); |
135
|
|
|
|
|
|
|
*Memcached::Client::prepend_multi = Memcached::Client::Request::AddMulti->generate ("prepend"); |
136
|
|
|
|
|
|
|
*Memcached::Client::replace_multi = Memcached::Client::Request::AddMulti->generate ("replace"); |
137
|
|
|
|
|
|
|
*Memcached::Client::set_multi = Memcached::Client::Request::AddMulti->generate ("set"); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
package Memcached::Client::Request::Decr; |
140
|
|
|
|
|
|
|
BEGIN { |
141
|
2
|
|
|
2
|
|
82
|
$Memcached::Client::Request::Decr::VERSION = '2.01'; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
# ABSTRACT: Driver for multiple Memcached::Client decr-style requests |
144
|
|
|
|
|
|
|
|
145
|
2
|
|
|
2
|
|
62
|
use Memcached::Client::Log qw{DEBUG}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
126
|
|
146
|
2
|
|
|
2
|
|
14
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
778
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub process { |
150
|
0
|
|
|
0
|
|
|
my ($self, $key, $delta, $initial) = @_; |
151
|
0
|
0
|
|
|
|
|
return () unless (defined $key); |
152
|
0
|
|
|
|
|
|
$self->log ("arguments are %s", \@_) if DEBUG; |
153
|
0
|
0
|
|
|
|
|
$self->{data} = defined $initial ? int ($initial) : undef; |
154
|
0
|
|
0
|
|
|
|
$self->{delta} = int ($delta || 1); |
155
|
0
|
|
|
|
|
|
$self->{key} = $key; |
156
|
0
|
|
|
|
|
|
$self->{type} = "__decr"; |
157
|
0
|
|
|
|
|
|
return $self; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
*Memcached::Client::decr = Memcached::Client::Request::Decr->generate ("decr"); |
161
|
|
|
|
|
|
|
*Memcached::Client::incr = Memcached::Client::Request::Decr->generate ("incr"); |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
package Memcached::Client::Request::DecrMulti; |
164
|
|
|
|
|
|
|
BEGIN { |
165
|
2
|
|
|
2
|
|
60
|
$Memcached::Client::Request::DecrMulti::VERSION = '2.01'; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
# ABSTRACT: Driver for multiple Memcached::Client decr-style requests |
168
|
|
|
|
|
|
|
|
169
|
2
|
|
|
2
|
|
28
|
use Memcached::Client::Log qw{DEBUG}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
124
|
|
170
|
2
|
|
|
2
|
|
10
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1100
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub process { |
174
|
0
|
|
|
0
|
|
|
my ($self, @requests) = @_; |
175
|
0
|
|
|
|
|
|
$self->{result} = {}; |
176
|
0
|
0
|
|
|
|
|
return () unless (@requests); |
177
|
0
|
|
|
|
|
|
$self->{partial} = 0; |
178
|
0
|
|
|
|
|
|
return grep {defined} map { |
|
0
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
my $request = bless {command => $self->{command}, sendkey => 1}, "Memcached::Client::Request::Decr"; |
180
|
|
|
|
|
|
|
$request->{cb} = sub { |
181
|
0
|
|
|
0
|
|
|
my ($key, $value) = @_; |
182
|
0
|
|
|
|
|
|
$self->log ("Noting that we received %s for %s", $value, $key) if DEBUG; |
183
|
0
|
0
|
|
|
|
|
$self->{result}->{$key} = $value if (defined $value); |
184
|
0
|
0
|
|
|
|
|
$self->result unless (--$self->{partial}); |
185
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
186
|
0
|
|
|
|
|
|
}; |
187
|
0
|
0
|
|
|
|
|
if ($request->process (ref $_ ? @{$_} : $_)) { |
|
0
|
0
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
$self->{partial}++; |
189
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
190
|
0
|
|
|
|
|
|
$request; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
} @requests; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
*Memcached::Client::decr_multi = Memcached::Client::Request::DecrMulti->generate ("decr"); |
196
|
|
|
|
|
|
|
*Memcached::Client::incr_multi = Memcached::Client::Request::DecrMulti->generate ("incr"); |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
package Memcached::Client::Request::Delete; |
199
|
|
|
|
|
|
|
BEGIN { |
200
|
2
|
|
|
2
|
|
48
|
$Memcached::Client::Request::Delete::VERSION = '2.01'; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
# ABSTRACT: Driver for Memcached::Client delete requests |
203
|
|
|
|
|
|
|
|
204
|
2
|
|
|
2
|
|
16
|
use Memcached::Client::Log qw{DEBUG}; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
308
|
|
205
|
2
|
|
|
2
|
|
14
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
456
|
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub process { |
209
|
0
|
|
|
0
|
|
|
my ($self, $key) = @_; |
210
|
0
|
|
|
|
|
|
$self->{default} = 0; |
211
|
0
|
0
|
|
|
|
|
return () unless (defined $key); |
212
|
0
|
|
|
|
|
|
$self->log ("arguments are %s", \@_) if DEBUG; |
213
|
0
|
|
|
|
|
|
$self->{key} = $key; |
214
|
0
|
|
|
|
|
|
$self->{type} = "__delete"; |
215
|
0
|
|
|
|
|
|
return $self; |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
*Memcached::Client::delete = Memcached::Client::Request::Delete->generate ("delete"); |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
package Memcached::Client::Request::DeleteMulti; |
221
|
|
|
|
|
|
|
BEGIN { |
222
|
2
|
|
|
2
|
|
48
|
$Memcached::Client::Request::DeleteMulti::VERSION = '2.01'; |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
# ABSTRACT: Driver for multiple Memcached::Client delete requests |
225
|
|
|
|
|
|
|
|
226
|
2
|
|
|
2
|
|
14
|
use Memcached::Client::Log qw{DEBUG}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
114
|
|
227
|
2
|
|
|
2
|
|
164
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
870
|
|
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub process { |
231
|
0
|
|
|
0
|
|
|
my ($self, @keys) = @_; |
232
|
0
|
|
|
|
|
|
$self->{result} = {}; |
233
|
0
|
0
|
|
|
|
|
return () unless (@keys); |
234
|
0
|
|
|
|
|
|
$self->{partial} = 0; |
235
|
0
|
|
|
|
|
|
return grep {$_} map { |
|
0
|
|
|
|
|
|
|
236
|
0
|
|
|
|
|
|
my $request = bless {command => $self->{command}, sendkey => 1}, "Memcached::Client::Request::Delete"; |
237
|
|
|
|
|
|
|
$request->{cb} = sub { |
238
|
0
|
|
|
0
|
|
|
my ($key, $value) = @_; |
239
|
0
|
|
|
|
|
|
$self->log ("Noting that we received %s for %s", $value, $key) if DEBUG; |
240
|
0
|
0
|
|
|
|
|
$self->{result}->{$key} = $value if (defined $value); |
241
|
0
|
0
|
|
|
|
|
$self->result unless (--$self->{partial}); |
242
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
243
|
0
|
|
|
|
|
|
}; |
244
|
0
|
0
|
|
|
|
|
if ($request->process ($_)) { |
245
|
0
|
|
|
|
|
|
$self->{partial}++; |
246
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
247
|
0
|
|
|
|
|
|
$request; |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
} @keys; |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
*Memcached::Client::delete_multi = Memcached::Client::Request::DeleteMulti->generate ("delete"); |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
package Memcached::Client::Request::Get; |
255
|
|
|
|
|
|
|
BEGIN { |
256
|
2
|
|
|
2
|
|
42
|
$Memcached::Client::Request::Get::VERSION = '2.01'; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
# ABSTRACT: Driver for Memcached::Client get requests |
259
|
|
|
|
|
|
|
|
260
|
2
|
|
|
2
|
|
12
|
use Memcached::Client::Log qw{DEBUG}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
292
|
|
261
|
2
|
|
|
2
|
|
12
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
396
|
|
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
sub process { |
265
|
0
|
|
|
0
|
|
|
my ($self, $key) = @_; |
266
|
0
|
0
|
|
|
|
|
return () unless (defined $key); |
267
|
0
|
|
|
|
|
|
$self->log ("arguments are %s", \@_) if DEBUG; |
268
|
0
|
|
|
|
|
|
$self->{type} = "__get"; |
269
|
0
|
|
|
|
|
|
$self->{key} = $key; |
270
|
0
|
|
|
|
|
|
return $self; |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
*Memcached::Client::get = Memcached::Client::Request::Get->generate ("get"); |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
package Memcached::Client::Request::GetMulti; |
276
|
|
|
|
|
|
|
BEGIN { |
277
|
2
|
|
|
2
|
|
44
|
$Memcached::Client::Request::GetMulti::VERSION = '2.01'; |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
# ABSTRACT: Driver for multiple Memcached::Client get requests |
280
|
|
|
|
|
|
|
|
281
|
2
|
|
|
2
|
|
12
|
use Memcached::Client::Log qw{DEBUG}; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
110
|
|
282
|
2
|
|
|
2
|
|
10
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
708
|
|
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
sub process { |
286
|
0
|
|
|
0
|
|
|
my ($self, @keys) = @_; |
287
|
0
|
|
|
|
|
|
$self->{result} = {}; |
288
|
0
|
0
|
|
|
|
|
return () unless (@keys); |
289
|
0
|
|
|
|
|
|
$self->{partial} = 0; |
290
|
0
|
|
|
|
|
|
return grep {defined} map { |
|
0
|
|
|
|
|
|
|
291
|
0
|
|
|
|
|
|
my $request = bless {command => $self->{command}, sendkey => 1}, "Memcached::Client::Request::Get"; |
292
|
|
|
|
|
|
|
$request->{cb} = sub { |
293
|
0
|
|
|
0
|
|
|
my ($key, $value) = @_; |
294
|
0
|
|
|
|
|
|
$self->log ("Noting that we received %s for %s", $value, $key) if DEBUG; |
295
|
0
|
0
|
|
|
|
|
$self->{result}->{$key} = $value if (defined $value); |
296
|
0
|
0
|
|
|
|
|
$self->result unless (--$self->{partial}); |
297
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
298
|
0
|
|
|
|
|
|
}; |
299
|
0
|
0
|
|
|
|
|
if ($request->process ($_)) { |
300
|
0
|
|
|
|
|
|
$self->{partial}++; |
301
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
302
|
0
|
|
|
|
|
|
$request; |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
} @keys; |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
*Memcached::Client::get_multi = Memcached::Client::Request::GetMulti->generate ("get"); |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
package Memcached::Client::Request::Broadcast; |
310
|
|
|
|
|
|
|
BEGIN { |
311
|
2
|
|
|
2
|
|
42
|
$Memcached::Client::Request::Broadcast::VERSION = '2.01'; |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
# ABSTRACT: Class to manage Memcached::Client server requests |
314
|
|
|
|
|
|
|
|
315
|
2
|
|
|
2
|
|
12
|
use Memcached::Client::Log qw{DEBUG LOG}; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
132
|
|
316
|
2
|
|
|
2
|
|
10
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
222
|
|
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub process { |
320
|
0
|
|
|
0
|
|
|
return $_[0]; |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
package Memcached::Client::Request::BroadcastMulti; |
324
|
|
|
|
|
|
|
BEGIN { |
325
|
2
|
|
|
2
|
|
52
|
$Memcached::Client::Request::BroadcastMulti::VERSION = '2.01'; |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
# ABSTRACT: Class to manage Memcached::Client broadcast requests |
328
|
|
|
|
|
|
|
|
329
|
2
|
|
|
2
|
|
10
|
use Memcached::Client::Log qw{DEBUG}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
272
|
|
330
|
2
|
|
|
2
|
|
10
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
1072
|
|
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub process { |
334
|
0
|
|
|
0
|
|
|
my ($self, @arguments) = @_; |
335
|
0
|
|
|
|
|
|
$self->{arguments} = \@arguments; |
336
|
0
|
|
|
|
|
|
$self->{result} = {}; |
337
|
0
|
|
|
|
|
|
$self->{partial} = 0; |
338
|
0
|
|
|
|
|
|
$self->{type} = "__$self->{command}"; |
339
|
0
|
|
|
|
|
|
return $self; |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
sub server { |
344
|
0
|
|
|
0
|
|
|
my ($self, $server) = @_; |
345
|
0
|
|
|
|
|
|
my $request = bless {command => $self->{command}, key => $server, sendkey => 1, type => $self->{type}}, "Memcached::Client::Request::Broadcast"; |
346
|
|
|
|
|
|
|
$request->{cb} = sub { |
347
|
0
|
|
|
0
|
|
|
my ($key, $value) = @_; |
348
|
0
|
|
|
|
|
|
$self->log ("Noting that we received %s for %s", $value, $key) if DEBUG; |
349
|
0
|
0
|
|
|
|
|
$self->{result}->{$key} = $value if (defined $value); |
350
|
0
|
0
|
|
|
|
|
$self->result unless (--$self->{partial}); |
351
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
352
|
0
|
|
|
|
|
|
}; |
353
|
0
|
|
|
|
|
|
$self->{partial}++; |
354
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
355
|
0
|
|
|
|
|
|
$request; |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
*Memcached::Client::flush_all = Memcached::Client::Request::BroadcastMulti->generate ("flush_all"); |
359
|
|
|
|
|
|
|
*Memcached::Client::stats = Memcached::Client::Request::BroadcastMulti->generate ("stats"); |
360
|
|
|
|
|
|
|
*Memcached::Client::version = Memcached::Client::Request::BroadcastMulti->generate ("version"); |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
package Memcached::Client::Request::Connect; |
363
|
|
|
|
|
|
|
BEGIN { |
364
|
2
|
|
|
2
|
|
62
|
$Memcached::Client::Request::Connect::VERSION = '2.01'; |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
# ABSTRACT: Class to manage Memcached::Client server request |
367
|
|
|
|
|
|
|
|
368
|
2
|
|
|
2
|
|
16
|
use Memcached::Client::Log qw{DEBUG LOG}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
134
|
|
369
|
2
|
|
|
2
|
|
12
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
232
|
|
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
sub process { |
373
|
0
|
|
|
0
|
|
|
return $_[0]; |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
package Memcached::Client::Request::ConnectMulti; |
377
|
|
|
|
|
|
|
BEGIN { |
378
|
2
|
|
|
2
|
|
40
|
$Memcached::Client::Request::ConnectMulti::VERSION = '2.01'; |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
# ABSTRACT: Class to manage Memcached::Client connection requests |
381
|
|
|
|
|
|
|
|
382
|
2
|
|
|
2
|
|
10
|
use Memcached::Client::Log qw{DEBUG}; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
102
|
|
383
|
2
|
|
|
2
|
|
10
|
use base qw{Memcached::Client::Request}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1176
|
|
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
sub process { |
387
|
0
|
|
|
0
|
|
|
return $_[0]; |
388
|
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
sub server { |
392
|
0
|
|
|
0
|
|
|
my ($self, $server) = @_; |
393
|
0
|
|
|
|
|
|
my $request = bless {command => "connect", key => $server, sendkey => 1, type => "__connect"}, "Memcached::Client::Request::Connect"; |
394
|
|
|
|
|
|
|
$request->{cb} = sub { |
395
|
0
|
|
|
0
|
|
|
my ($key, $value) = @_; |
396
|
0
|
|
|
|
|
|
$self->log ("Noting that we received %s for %s", $value, $key) if DEBUG; |
397
|
0
|
0
|
|
|
|
|
$self->{result}->{$key} = $value if (defined $value); |
398
|
0
|
0
|
|
|
|
|
$self->result (1) unless (--$self->{partial}); |
399
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
400
|
0
|
|
|
|
|
|
}; |
401
|
0
|
|
|
|
|
|
$self->{partial}++; |
402
|
0
|
|
|
|
|
|
$self->log ("%d queries outstanding", $self->{partial}) if DEBUG; |
403
|
0
|
|
|
|
|
|
$request; |
404
|
|
|
|
|
|
|
} |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
*Memcached::Client::connect = Memcached::Client::Request::ConnectMulti->generate ("connect"); |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
1; |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
__END__ |