line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
|
|
|
|
|
|
# See the end of the file for copyright and license. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Cache::Memcached::Fast; |
6
|
1
|
|
|
1
|
|
748
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
42
|
|
7
|
1
|
|
|
1
|
|
6
|
use 5.006; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
9
|
|
|
|
|
|
|
use warnings; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#line 19 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.19'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#line 130 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Carp; |
21
|
|
|
|
|
|
|
use Storable; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
require XSLoader; |
24
|
|
|
|
|
|
|
XSLoader::load('Cache::Memcached::Fast', $VERSION); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#line 491 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our %known_params = ( |
30
|
|
|
|
|
|
|
servers => [ { address => 1, weight => 1, noreply => 1 } ], |
31
|
|
|
|
|
|
|
namespace => 1, |
32
|
|
|
|
|
|
|
nowait => 1, |
33
|
|
|
|
|
|
|
hash_namespace => 1, |
34
|
|
|
|
|
|
|
connect_timeout => 1, |
35
|
|
|
|
|
|
|
io_timeout => 1, |
36
|
|
|
|
|
|
|
select_timeout => 1, |
37
|
|
|
|
|
|
|
close_on_error => 1, |
38
|
|
|
|
|
|
|
compress_threshold => 1, |
39
|
|
|
|
|
|
|
compress_ratio => 1, |
40
|
|
|
|
|
|
|
compress_methods => 1, |
41
|
|
|
|
|
|
|
compress_algo => sub { |
42
|
|
|
|
|
|
|
carp "compress_algo has been removed in 0.08," |
43
|
|
|
|
|
|
|
. " use compress_methods instead" |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
max_failures => 1, |
46
|
|
|
|
|
|
|
failure_timeout => 1, |
47
|
|
|
|
|
|
|
ketama_points => 1, |
48
|
|
|
|
|
|
|
serialize_methods => 1, |
49
|
|
|
|
|
|
|
utf8 => 1, |
50
|
|
|
|
|
|
|
max_size => 1, |
51
|
|
|
|
|
|
|
check_args => 1, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _check_args { |
56
|
|
|
|
|
|
|
my ($checker, $args, $level) = @_; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$level = 0 unless defined $level; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my @unknown; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
if (ref($args) ne 'HASH') { |
63
|
|
|
|
|
|
|
if (ref($args) eq 'ARRAY' and ref($checker) eq 'ARRAY') { |
64
|
|
|
|
|
|
|
foreach my $v (@$args) { |
65
|
|
|
|
|
|
|
push @unknown, _check_args($checker->[0], $v, $level + 1); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
return @unknown; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
if (exists $args->{check_args} |
72
|
|
|
|
|
|
|
and lc($args->{check_args}) eq 'skip') { |
73
|
|
|
|
|
|
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
while (my ($k, $v) = each %$args) { |
77
|
|
|
|
|
|
|
if (exists $checker->{$k}) { |
78
|
|
|
|
|
|
|
if (ref($checker->{$k}) eq 'CODE') { |
79
|
|
|
|
|
|
|
$checker->{$k}->($args, $k, $v); |
80
|
|
|
|
|
|
|
} elsif (ref($checker->{$k})) { |
81
|
|
|
|
|
|
|
push @unknown, _check_args($checker->{$k}, $v, $level + 1); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} else { |
84
|
|
|
|
|
|
|
push @unknown, $k; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
if ($level > 0) { |
89
|
|
|
|
|
|
|
return @unknown; |
90
|
|
|
|
|
|
|
} else { |
91
|
|
|
|
|
|
|
carp "Unknown parameter: @unknown" if @unknown; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
our %instance; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub new { |
99
|
|
|
|
|
|
|
my Cache::Memcached::Fast $class = shift; |
100
|
|
|
|
|
|
|
my ($conf) = @_; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
_check_args(\%known_params, $conf); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
if (not $conf->{compress_methods} and eval "require Compress::Zlib") { |
105
|
|
|
|
|
|
|
# Note that the functions below can't return false when |
106
|
|
|
|
|
|
|
# operation succeed. This is because "" and "0" compress to a |
107
|
|
|
|
|
|
|
# longer values (because of additional format data), and |
108
|
|
|
|
|
|
|
# compress_ratio will force them to be stored uncompressed, |
109
|
|
|
|
|
|
|
# thus decompression will never return them. |
110
|
|
|
|
|
|
|
$conf->{compress_methods} = [ |
111
|
|
|
|
|
|
|
sub { ${$_[1]} = Compress::Zlib::memGzip(${$_[0]}) }, |
112
|
|
|
|
|
|
|
sub { ${$_[1]} = Compress::Zlib::memGunzip(${$_[0]}) } |
113
|
|
|
|
|
|
|
]; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
if ($conf->{utf8} and $^V lt v5.8.1) { |
117
|
|
|
|
|
|
|
carp "'utf8' may be enabled only for Perl >= 5.8.1, disabled"; |
118
|
|
|
|
|
|
|
undef $conf->{utf8}; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
$conf->{serialize_methods} ||= [ \&Storable::nfreeze, \&Storable::thaw ]; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
my $memd = Cache::Memcached::Fast::_new($class, $conf); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
if (eval "require Scalar::Util") { |
126
|
|
|
|
|
|
|
my $context = [$memd, $conf]; |
127
|
|
|
|
|
|
|
Scalar::Util::weaken($context->[0]); |
128
|
|
|
|
|
|
|
$instance{$$memd} = $context; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
return $memd; |
132
|
1
|
|
|
1
|
|
6
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
133
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1188
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub CLONE { |
136
|
|
|
|
|
|
|
my ($class) = @_; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
my @contexts = values %instance; |
139
|
|
|
|
|
|
|
%instance = (); |
140
|
|
|
|
|
|
|
foreach my $context (@contexts) { |
141
|
|
|
|
|
|
|
my $memd = Cache::Memcached::Fast::_new($class, $context->[1]); |
142
|
|
|
|
|
|
|
${$context->[0]} = $$memd; |
143
|
|
|
|
|
|
|
$instance{$$memd} = $context; |
144
|
|
|
|
|
|
|
$$memd = 0; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub DESTROY { |
150
|
|
|
|
|
|
|
my ($memd) = @_; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
return unless $$memd; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
delete $instance{$$memd}; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Cache::Memcached::Fast::_destroy($memd); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
#line 641 |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# See Fast.xs. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
#line 658 |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# See Fast.xs. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
#line 681 |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# See Fast.xs. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
#line 707 |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# See Fast.xs. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
#line 733 |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# See Fast.xs. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
#line 761 |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# See Fast.xs. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
#line 780 |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# See Fast.xs. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
#line 806 |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# See Fast.xs. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
#line 825 |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
# See Fast.xs. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
#line 851 |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# See Fast.xs. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
#line 871 |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# See Fast.xs. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
#line 897 |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# See Fast.xs. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
#line 917 |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# See Fast.xs. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
#line 943 |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
# See Fast.xs. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
#line 956 |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
# See Fast.xs. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
#line 971 |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# See Fast.xs. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
#line 995 |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
# See Fast.xs. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
#line 1012 |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
# See Fast.xs. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
#line 1030 |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
# See Fast.xs. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
#line 1057 |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
# See Fast.xs. |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
#line 1078 |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
# See Fast.xs. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
#line 1105 |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
# See Fast.xs. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
#line 1119 |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
# See Fast.xs. |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
#line 1128 |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
*remove = \&delete; |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
#line 1149 |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
# See Fast.xs. |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
#line 1174 |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
# See Fast.xs. |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
#line 1197 |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
# See Fast.xs. |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
#line 1212 |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
# See Fast.xs. |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
#line 1228 |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
# See Fast.xs. |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
1; |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
__END__ |