| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
MODULE = Cache::FastMmap::CImpl PACKAGE = Cache::FastMmap::CImpl |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
SV * |
|
16
|
|
|
|
|
|
|
fc_new() |
|
17
|
|
|
|
|
|
|
INIT: |
|
18
|
|
|
|
|
|
|
mmap_cache * cache; |
|
19
|
|
|
|
|
|
|
SV * obj_pnt, * obj; |
|
20
|
|
|
|
|
|
|
CODE: |
|
21
|
10
|
|
|
|
|
|
cache = mmc_new(); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
/* Create integer which is pointer to cache object */ |
|
24
|
10
|
|
|
|
|
|
obj_pnt = newSViv((IV)cache); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
/* Create reference to integer value. This will be the object */ |
|
27
|
10
|
|
|
|
|
|
obj = newRV_noinc((SV *)obj_pnt); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
RETVAL = obj; |
|
30
|
|
|
|
|
|
|
OUTPUT: |
|
31
|
|
|
|
|
|
|
RETVAL |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
NO_OUTPUT int |
|
34
|
|
|
|
|
|
|
fc_set_param(obj, param, val) |
|
35
|
|
|
|
|
|
|
SV * obj; |
|
36
|
|
|
|
|
|
|
char * param; |
|
37
|
|
|
|
|
|
|
char * val; |
|
38
|
|
|
|
|
|
|
INIT: |
|
39
|
|
|
|
|
|
|
mmap_cache * cache; |
|
40
|
70
|
|
|
|
|
|
if (!SvROK(obj)) { |
|
41
|
0
|
|
|
|
|
|
croak("Object not reference"); |
|
42
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
70
|
|
|
|
|
|
obj = SvRV(obj); |
|
45
|
70
|
|
|
|
|
|
if (!SvIOKp(obj)) { |
|
46
|
0
|
|
|
|
|
|
croak("Object not initiliased correctly"); |
|
47
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
70
|
|
|
|
|
|
cache = (mmap_cache *)SvIV(obj); |
|
50
|
70
|
|
|
|
|
|
if (!cache) { |
|
51
|
0
|
|
|
|
|
|
croak("Object not created correctly"); |
|
52
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
CODE: |
|
56
|
70
|
|
|
|
|
|
RETVAL = mmc_set_param(cache, param, val); |
|
57
|
70
|
|
|
|
|
|
POST_CALL: |
|
58
|
70
|
|
|
|
|
|
if (RETVAL != 0) { |
|
59
|
0
|
|
|
|
|
|
croak(mmc_error(cache)); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
NO_OUTPUT int |
|
63
|
|
|
|
|
|
|
fc_init(obj) |
|
64
|
|
|
|
|
|
|
SV * obj; |
|
65
|
|
|
|
|
|
|
INIT: |
|
66
|
|
|
|
|
|
|
mmap_cache * cache; |
|
67
|
10
|
|
|
|
|
|
if (!SvROK(obj)) { |
|
68
|
0
|
|
|
|
|
|
croak("Object not reference"); |
|
69
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
10
|
|
|
|
|
|
obj = SvRV(obj); |
|
72
|
10
|
|
|
|
|
|
if (!SvIOKp(obj)) { |
|
73
|
0
|
|
|
|
|
|
croak("Object not initiliased correctly"); |
|
74
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
10
|
|
|
|
|
|
cache = (mmap_cache *)SvIV(obj); |
|
77
|
10
|
|
|
|
|
|
if (!cache) { |
|
78
|
0
|
|
|
|
|
|
croak("Object not created correctly"); |
|
79
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
CODE: |
|
83
|
10
|
|
|
|
|
|
RETVAL = mmc_init(cache); |
|
84
|
10
|
|
|
|
|
|
POST_CALL: |
|
85
|
10
|
|
|
|
|
|
if (RETVAL != 0) { |
|
86
|
0
|
|
|
|
|
|
croak(mmc_error(cache)); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
void |
|
91
|
|
|
|
|
|
|
fc_close(obj) |
|
92
|
|
|
|
|
|
|
SV * obj |
|
93
|
|
|
|
|
|
|
INIT: |
|
94
|
|
|
|
|
|
|
mmap_cache * cache; |
|
95
|
10
|
|
|
|
|
|
if (!SvROK(obj)) { |
|
96
|
0
|
|
|
|
|
|
croak("Object not reference"); |
|
97
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
10
|
|
|
|
|
|
obj = SvRV(obj); |
|
100
|
10
|
|
|
|
|
|
if (!SvIOKp(obj)) { |
|
101
|
0
|
|
|
|
|
|
croak("Object not initiliased correctly"); |
|
102
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
10
|
|
|
|
|
|
cache = (mmap_cache *)SvIV(obj); |
|
105
|
10
|
|
|
|
|
|
if (!cache) { |
|
106
|
0
|
|
|
|
|
|
croak("Object not created correctly"); |
|
107
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
CODE: |
|
111
|
10
|
|
|
|
|
|
mmc_close(cache); |
|
112
|
10
|
|
|
|
|
|
sv_setiv(obj, 0); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
void |
|
116
|
|
|
|
|
|
|
fc_hash(obj, key); |
|
117
|
|
|
|
|
|
|
SV * obj; |
|
118
|
|
|
|
|
|
|
SV * key; |
|
119
|
|
|
|
|
|
|
INIT: |
|
120
|
|
|
|
|
|
|
mmap_cache * cache; |
|
121
|
|
|
|
|
|
|
int key_len; |
|
122
|
|
|
|
|
|
|
void * key_ptr; |
|
123
|
|
|
|
|
|
|
MU32 hash_page, hash_slot; |
|
124
|
|
|
|
|
|
|
STRLEN pl_key_len; |
|
125
|
|
|
|
|
|
|
|
|
126
|
60778
|
|
|
|
|
|
if (!SvROK(obj)) { |
|
127
|
0
|
|
|
|
|
|
croak("Object not reference"); |
|
128
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
60778
|
|
|
|
|
|
obj = SvRV(obj); |
|
131
|
60778
|
|
|
|
|
|
if (!SvIOKp(obj)) { |
|
132
|
0
|
|
|
|
|
|
croak("Object not initiliased correctly"); |
|
133
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
60778
|
|
|
|
|
|
cache = (mmap_cache *)SvIV(obj); |
|
136
|
60778
|
|
|
|
|
|
if (!cache) { |
|
137
|
0
|
|
|
|
|
|
croak("Object not created correctly"); |
|
138
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
PPCODE: |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
/* Get key length, data pointer */ |
|
144
|
60778
|
|
|
|
|
|
key_ptr = (void *)SvPV(key, pl_key_len); |
|
145
|
|
|
|
|
|
|
key_len = (int)pl_key_len; |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
/* Hash key to get page and slot */ |
|
148
|
60778
|
|
|
|
|
|
mmc_hash(cache, key_ptr, key_len, &hash_page, &hash_slot); |
|
149
|
|
|
|
|
|
|
|
|
150
|
60778
|
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv((IV)hash_page))); |
|
151
|
60778
|
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv((IV)hash_slot))); |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
NO_OUTPUT int |
|
155
|
|
|
|
|
|
|
fc_lock(obj, page); |
|
156
|
|
|
|
|
|
|
SV * obj; |
|
157
|
|
|
|
|
|
|
UV page; |
|
158
|
|
|
|
|
|
|
INIT: |
|
159
|
|
|
|
|
|
|
mmap_cache * cache; |
|
160
|
|
|
|
|
|
|
|
|
161
|
61051
|
|
|
|
|
|
if (!SvROK(obj)) { |
|
162
|
0
|
|
|
|
|
|
croak("Object not reference"); |
|
163
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
61051
|
|
|
|
|
|
obj = SvRV(obj); |
|
166
|
61051
|
|
|
|
|
|
if (!SvIOKp(obj)) { |
|
167
|
0
|
|
|
|
|
|
croak("Object not initiliased correctly"); |
|
168
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
61051
|
|
|
|
|
|
cache = (mmap_cache *)SvIV(obj); |
|
171
|
61051
|
|
|
|
|
|
if (!cache) { |
|
172
|
0
|
|
|
|
|
|
croak("Object not created correctly"); |
|
173
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
CODE: |
|
177
|
61051
|
|
|
|
|
|
RETVAL = mmc_lock(cache, (MU32)page); |
|
178
|
61051
|
|
|
|
|
|
POST_CALL: |
|
179
|
61051
|
|
|
|
|
|
if (RETVAL != 0) { |
|
180
|
0
|
|
|
|
|
|
croak(mmc_error(cache)); |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
NO_OUTPUT int |
|
185
|
|
|
|
|
|
|
fc_unlock(obj); |
|
186
|
|
|
|
|
|
|
SV * obj; |
|
187
|
|
|
|
|
|
|
INIT: |
|
188
|
|
|
|
|
|
|
mmap_cache * cache; |
|
189
|
|
|
|
|
|
|
|
|
190
|
61051
|
|
|
|
|
|
if (!SvROK(obj)) { |
|
191
|
0
|
|
|
|
|
|
croak("Object not reference"); |
|
192
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
61051
|
|
|
|
|
|
obj = SvRV(obj); |
|
195
|
61051
|
|
|
|
|
|
if (!SvIOKp(obj)) { |
|
196
|
0
|
|
|
|
|
|
croak("Object not initiliased correctly"); |
|
197
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
198
|
|
|
|
|
|
|
} |
|
199
|
61051
|
|
|
|
|
|
cache = (mmap_cache *)SvIV(obj); |
|
200
|
61051
|
|
|
|
|
|
if (!cache) { |
|
201
|
0
|
|
|
|
|
|
croak("Object not created correctly"); |
|
202
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
CODE: |
|
206
|
61051
|
|
|
|
|
|
RETVAL = mmc_unlock(cache); |
|
207
|
61051
|
|
|
|
|
|
POST_CALL: |
|
208
|
61051
|
|
|
|
|
|
if (RETVAL != 0) { |
|
209
|
0
|
|
|
|
|
|
croak(mmc_error(cache)); |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
void |
|
215
|
|
|
|
|
|
|
fc_read(obj, hash_slot, key) |
|
216
|
|
|
|
|
|
|
SV * obj; |
|
217
|
|
|
|
|
|
|
U32 hash_slot; |
|
218
|
|
|
|
|
|
|
SV * key; |
|
219
|
|
|
|
|
|
|
INIT: |
|
220
|
|
|
|
|
|
|
mmap_cache * cache; |
|
221
|
|
|
|
|
|
|
int key_len, val_len, found; |
|
222
|
|
|
|
|
|
|
void * key_ptr, * val_ptr; |
|
223
|
45623
|
|
|
|
|
|
MU32 flags = 0; |
|
224
|
|
|
|
|
|
|
STRLEN pl_key_len; |
|
225
|
|
|
|
|
|
|
SV * val; |
|
226
|
|
|
|
|
|
|
|
|
227
|
45623
|
|
|
|
|
|
if (!SvROK(obj)) { |
|
228
|
0
|
|
|
|
|
|
croak("Object not reference"); |
|
229
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
45623
|
|
|
|
|
|
obj = SvRV(obj); |
|
232
|
45623
|
|
|
|
|
|
if (!SvIOKp(obj)) { |
|
233
|
0
|
|
|
|
|
|
croak("Object not initiliased correctly"); |
|
234
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
235
|
|
|
|
|
|
|
} |
|
236
|
45623
|
|
|
|
|
|
cache = (mmap_cache *)SvIV(obj); |
|
237
|
45623
|
|
|
|
|
|
if (!cache) { |
|
238
|
0
|
|
|
|
|
|
croak("Object not created correctly"); |
|
239
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
PPCODE: |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
/* Get key length, data pointer */ |
|
246
|
45623
|
|
|
|
|
|
key_ptr = (void *)SvPV(key, pl_key_len); |
|
247
|
|
|
|
|
|
|
key_len = (int)pl_key_len; |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
/* Get value data pointer */ |
|
250
|
45623
|
|
|
|
|
|
found = mmc_read(cache, (MU32)hash_slot, key_ptr, key_len, &val_ptr, &val_len, &flags); |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
/* If not found, use undef */ |
|
253
|
45623
|
|
|
|
|
|
if (found == -1) { |
|
254
|
|
|
|
|
|
|
val = &PL_sv_undef; |
|
255
|
|
|
|
|
|
|
} else { |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
/* Cached an undef value? */ |
|
258
|
31020
|
|
|
|
|
|
if (flags & FC_UNDEF) { |
|
259
|
|
|
|
|
|
|
val = &PL_sv_undef; |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
} else { |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
/* Create PERL SV */ |
|
264
|
31020
|
|
|
|
|
|
val = sv_2mortal(newSVpvn((const char *)val_ptr, val_len)); |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
/* Make UTF8 if stored from UTF8 */ |
|
267
|
31020
|
|
|
|
|
|
if (flags & FC_UTF8VAL) { |
|
268
|
2
|
|
|
|
|
|
SvUTF8_on(val); |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
} |
|
272
|
31020
|
|
|
|
|
|
flags = flags & ~(FC_UTF8KEY | FC_UTF8VAL | FC_UNDEF); |
|
273
|
|
|
|
|
|
|
} |
|
274
|
|
|
|
|
|
|
|
|
275
|
45623
|
|
|
|
|
|
XPUSHs(val); |
|
276
|
45623
|
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv((IV)flags))); |
|
277
|
45623
|
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv((IV)!found))); |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
int |
|
281
|
|
|
|
|
|
|
fc_write(obj, hash_slot, key, val, in_flags) |
|
282
|
|
|
|
|
|
|
SV * obj; |
|
283
|
|
|
|
|
|
|
U32 hash_slot; |
|
284
|
|
|
|
|
|
|
SV * key; |
|
285
|
|
|
|
|
|
|
SV * val; |
|
286
|
|
|
|
|
|
|
U32 in_flags; |
|
287
|
|
|
|
|
|
|
INIT: |
|
288
|
|
|
|
|
|
|
mmap_cache * cache; |
|
289
|
|
|
|
|
|
|
int key_len, val_len; |
|
290
|
|
|
|
|
|
|
void * key_ptr, * val_ptr; |
|
291
|
|
|
|
|
|
|
STRLEN pl_key_len, pl_val_len; |
|
292
|
|
|
|
|
|
|
|
|
293
|
28671
|
|
|
|
|
|
if (!SvROK(obj)) { |
|
294
|
0
|
|
|
|
|
|
croak("Object not reference"); |
|
295
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
296
|
|
|
|
|
|
|
} |
|
297
|
28671
|
|
|
|
|
|
obj = SvRV(obj); |
|
298
|
28671
|
|
|
|
|
|
if (!SvIOKp(obj)) { |
|
299
|
0
|
|
|
|
|
|
croak("Object not initiliased correctly"); |
|
300
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
301
|
|
|
|
|
|
|
} |
|
302
|
28671
|
|
|
|
|
|
cache = (mmap_cache *)SvIV(obj); |
|
303
|
28671
|
|
|
|
|
|
if (!cache) { |
|
304
|
0
|
|
|
|
|
|
croak("Object not created correctly"); |
|
305
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
306
|
|
|
|
|
|
|
} |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
CODE: |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
/* Get key length, data pointer */ |
|
312
|
28671
|
|
|
|
|
|
key_ptr = (void *)SvPV(key, pl_key_len); |
|
313
|
28671
|
|
|
|
|
|
key_len = (int)pl_key_len; |
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
/* Check for storing undef, and store empty string with undef flag set */ |
|
316
|
28671
|
|
|
|
|
|
if (val == &PL_sv_undef) { |
|
317
|
0
|
|
|
|
|
|
in_flags |= FC_UNDEF; |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
val_ptr = ""; |
|
320
|
|
|
|
|
|
|
val_len = 0; |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
} else { |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
/* Get key length, data pointer */ |
|
325
|
28671
|
|
|
|
|
|
val_ptr = (void *)SvPV(val, pl_val_len); |
|
326
|
28671
|
|
|
|
|
|
val_len = (int)pl_val_len; |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
/* Set UTF8-ness flag of stored value */ |
|
329
|
28671
|
|
|
|
|
|
if (SvUTF8(val)) { |
|
330
|
3
|
|
|
|
|
|
in_flags |= FC_UTF8VAL; |
|
331
|
|
|
|
|
|
|
} |
|
332
|
28671
|
|
|
|
|
|
if (SvUTF8(key)) { |
|
333
|
4
|
|
|
|
|
|
in_flags |= FC_UTF8KEY; |
|
334
|
|
|
|
|
|
|
} |
|
335
|
|
|
|
|
|
|
} |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
/* Write value to cache */ |
|
338
|
28671
|
|
|
|
|
|
RETVAL = mmc_write(cache, (MU32)hash_slot, key_ptr, key_len, val_ptr, val_len, (MU32)in_flags); |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
OUTPUT: |
|
341
|
|
|
|
|
|
|
RETVAL |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
int |
|
344
|
|
|
|
|
|
|
fc_delete(obj, hash_slot, key) |
|
345
|
|
|
|
|
|
|
SV * obj; |
|
346
|
|
|
|
|
|
|
U32 hash_slot; |
|
347
|
|
|
|
|
|
|
SV * key; |
|
348
|
|
|
|
|
|
|
INIT: |
|
349
|
|
|
|
|
|
|
mmap_cache * cache; |
|
350
|
|
|
|
|
|
|
MU32 out_flags; |
|
351
|
|
|
|
|
|
|
int key_len, did_delete; |
|
352
|
|
|
|
|
|
|
void * key_ptr; |
|
353
|
|
|
|
|
|
|
STRLEN pl_key_len; |
|
354
|
|
|
|
|
|
|
|
|
355
|
301
|
|
|
|
|
|
if (!SvROK(obj)) { |
|
356
|
0
|
|
|
|
|
|
croak("Object not reference"); |
|
357
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
358
|
|
|
|
|
|
|
} |
|
359
|
301
|
|
|
|
|
|
obj = SvRV(obj); |
|
360
|
301
|
|
|
|
|
|
if (!SvIOKp(obj)) { |
|
361
|
0
|
|
|
|
|
|
croak("Object not initiliased correctly"); |
|
362
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
363
|
|
|
|
|
|
|
} |
|
364
|
301
|
|
|
|
|
|
cache = (mmap_cache *)SvIV(obj); |
|
365
|
301
|
|
|
|
|
|
if (!cache) { |
|
366
|
0
|
|
|
|
|
|
croak("Object not created correctly"); |
|
367
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
368
|
|
|
|
|
|
|
} |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
PPCODE: |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
/* Get key length, data pointer */ |
|
374
|
301
|
|
|
|
|
|
key_ptr = (void *)SvPV(key, pl_key_len); |
|
375
|
|
|
|
|
|
|
key_len = (int)pl_key_len; |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
/* Write value to cache */ |
|
378
|
301
|
|
|
|
|
|
did_delete = mmc_delete(cache, (MU32)hash_slot, key_ptr, key_len, &out_flags); |
|
379
|
|
|
|
|
|
|
|
|
380
|
301
|
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv((IV)did_delete))); |
|
381
|
301
|
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv((IV)out_flags))); |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
void |
|
385
|
|
|
|
|
|
|
fc_expunge(obj, mode, wb, len) |
|
386
|
|
|
|
|
|
|
SV * obj; |
|
387
|
|
|
|
|
|
|
int mode; |
|
388
|
|
|
|
|
|
|
int wb; |
|
389
|
|
|
|
|
|
|
int len; |
|
390
|
|
|
|
|
|
|
INIT: |
|
391
|
|
|
|
|
|
|
mmap_cache * cache; |
|
392
|
28944
|
|
|
|
|
|
MU32 new_num_slots = 0, ** to_expunge = 0; |
|
393
|
|
|
|
|
|
|
int num_expunge, item; |
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
void * key_ptr, * val_ptr; |
|
396
|
|
|
|
|
|
|
int key_len, val_len; |
|
397
|
|
|
|
|
|
|
MU32 last_access, expire_time, flags; |
|
398
|
|
|
|
|
|
|
|
|
399
|
28944
|
|
|
|
|
|
if (!SvROK(obj)) { |
|
400
|
0
|
|
|
|
|
|
croak("Object not reference"); |
|
401
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
402
|
|
|
|
|
|
|
} |
|
403
|
28944
|
|
|
|
|
|
obj = SvRV(obj); |
|
404
|
28944
|
|
|
|
|
|
if (!SvIOKp(obj)) { |
|
405
|
0
|
|
|
|
|
|
croak("Object not initiliased correctly"); |
|
406
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
407
|
|
|
|
|
|
|
} |
|
408
|
28944
|
|
|
|
|
|
cache = (mmap_cache *)SvIV(obj); |
|
409
|
28944
|
|
|
|
|
|
if (!cache) { |
|
410
|
0
|
|
|
|
|
|
croak("Object not created correctly"); |
|
411
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
412
|
|
|
|
|
|
|
} |
|
413
|
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
PPCODE: |
|
415
|
|
|
|
|
|
|
|
|
416
|
28944
|
|
|
|
|
|
num_expunge = mmc_calc_expunge(cache, mode, len, &new_num_slots, &to_expunge); |
|
417
|
28944
|
|
|
|
|
|
if (to_expunge) { |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
/* Want list of expunged keys/values? */ |
|
420
|
7413
|
|
|
|
|
|
if (wb) { |
|
421
|
|
|
|
|
|
|
|
|
422
|
16758
|
|
|
|
|
|
for (item = 0; item < num_expunge; item++) { |
|
423
|
11202
|
|
|
|
|
|
mmc_get_details(cache, to_expunge[item], |
|
424
|
|
|
|
|
|
|
&key_ptr, &key_len, &val_ptr, &val_len, |
|
425
|
|
|
|
|
|
|
&last_access, &expire_time, &flags); |
|
426
|
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
{ |
|
428
|
11202
|
|
|
|
|
|
HV * ih = (HV *)sv_2mortal((SV *)newHV()); |
|
429
|
|
|
|
|
|
|
|
|
430
|
11202
|
|
|
|
|
|
SV * key = newSVpvn((const char *)key_ptr, key_len); |
|
431
|
11202
|
|
|
|
|
|
SV * val = newSVpvn((const char *)val_ptr, val_len); |
|
432
|
|
|
|
|
|
|
|
|
433
|
11202
|
|
|
|
|
|
|