| 1 |
|
| /* |
| 2 |
|
| * vim: expandtab:sw=4 |
| 3 |
|
| * */ |
| 4 |
|
| #include "EXTERN.h" |
| 5 |
|
| #include "perl.h" |
| 6 |
|
| #include "XSUB.h" |
| 7 |
|
| |
| 8 |
|
| #include "ppport.h" |
| 9 |
|
| |
| 10 |
|
| #include <libmemcached/memcached.h> |
| 11 |
|
| |
| 12 |
|
| #define MEMCACHED_CALLBACK_MALLOC_FUNCTION 4 |
| 13 |
|
| #define MEMCACHED_CALLBACK_REALLOC_FUNCTION 5 |
| 14 |
|
| #define MEMCACHED_CALLBACK_FREE_FUNCTION 6 |
| 15 |
|
| |
| 16 |
|
| /* See also the typemap as most of the interesting glue is there */ |
| 17 |
|
| |
| 18 |
|
| /* mapping C types to perl classes - keep typemap file in sync */ |
| 19 |
|
| typedef memcached_st* Memcached__libmemcached; |
| 20 |
|
| typedef uint32_t lmc_data_flags_t; |
| 21 |
|
| typedef char* lmc_key; |
| 22 |
|
| typedef char* lmc_value; |
| 23 |
|
| typedef time_t lmc_expiration; |
| 24 |
|
| |
| 25 |
|
| /* pointer chasing: |
| 26 |
|
| * |
| 27 |
|
| * $memc is a scalar (SV) containing a reference (RV) to a hash (HV) with magic (mg): |
| 28 |
|
| * |
| 29 |
|
| * RV -> HV -> mg -> lmc_state -> memcached_st (-> MEMCACHED_CALLBACK_USER_DATA points back to lmc_state) |
| 30 |
|
| * |
| 31 |
|
| */ |
| 32 |
|
| |
| 33 |
|
| /* get a memcached_st structure from a $memc */ |
| 34 |
|
| #define LMC_STATE_FROM_SV(sv) \ |
| 35 |
|
| (mg_find(SvRV(sv), '~')->mg_obj) |
| 36 |
|
| |
| 37 |
|
| #define LMC_PTR_FROM_SV(sv) \ |
| 38 |
|
| ((lmc_state_st*)LMC_STATE_FROM_SV(sv))->ptr |
| 39 |
|
| |
| 40 |
|
| /* get our lmc_state structure from a memcached_st ptr */ |
| 41 |
|
| #define LMC_STATE_FROM_PTR(ptr) \ |
| 42 |
|
| ((lmc_state_st*)memcached_callback_get(ptr, MEMCACHED_CALLBACK_USER_DATA, NULL)) |
| 43 |
|
| |
| 44 |
|
| /* get trace level from memcached_st ptr */ |
| 45 |
|
| #define LMC_TRACE_LEVEL_FROM_PTR(ptr) \ |
| 46 |
|
| ((ptr) ? LMC_STATE_FROM_PTR(ptr)->trace_level : 0) |
| 47 |
|
| |
| 48 |
|
| /* check memcached_return value counts as success */ |
| 49 |
|
| #define LMC_RETURN_OK(ret) \ |
| 50 |
|
| (ret==MEMCACHED_SUCCESS || ret==MEMCACHED_STORED || ret==MEMCACHED_DELETED || ret==MEMCACHED_END || ret==MEMCACHED_BUFFERED) |
| 51 |
|
| |
| 52 |
|
| /* store memcached_return value in our lmc_state structure */ |
| 53 |
|
| #define LMC_RECORD_RETURN_ERR(what, ptr, ret) \ |
| 54 |
|
| STMT_START { \ |
| 55 |
|
| lmc_state_st* lmc_state = LMC_STATE_FROM_PTR(ptr); \ |
| 56 |
|
| if (lmc_state) { \ |
| 57 |
|
| if (lmc_state->trace_level > 1 || (lmc_state->trace_level && !LMC_RETURN_OK(ret))) \ |
| 58 |
|
| warn("\t<= %s return %d %s", what, ret, memcached_strerror(ptr, ret)); \ |
| 59 |
|
| lmc_state->last_return = ret; \ |
| 60 |
|
| lmc_state->last_errno = memcached_last_error_errno(ptr); /* if MEMCACHED_ERRNO */ \ |
| 61 |
|
| } else { /* should never happen */ \ |
| 62 |
|
| warn("LMC_RECORD_RETURN_ERR(%d %s): no lmc_state structure in memcached_st so error not recorded!", \ |
| 63 |
|
| ret, memcached_strerror(ptr, ret)); \ |
| 64 |
|
| } \ |
| 65 |
|
| } STMT_END |
| 66 |
|
| |
| 67 |
|
| |
| 68 |
|
| /* ====================================================================================== */ |
| 69 |
|
| |
| 70 |
|
| |
| 71 |
|
| typedef struct lmc_state_st lmc_state_st; |
| 72 |
|
| typedef struct lmc_cb_context_st lmc_cb_context_st; |
| 73 |
|
| |
| 74 |
|
| /* context information for callbacks */ |
| 75 |
|
| struct lmc_cb_context_st { |
| 76 |
|
| lmc_state_st *lmc_state; |
| 77 |
|
| SV *dest_sv; |
| 78 |
|
| HV *dest_hv; |
| 79 |
|
| memcached_return *rc_ptr; |
| 80 |
|
| lmc_data_flags_t *flags_ptr; |
| 81 |
|
| UV result_count; |
| 82 |
|
| SV *get_cb; |
| 83 |
|
| SV *set_cb; |
| 84 |
|
| /* current set of keys for mget */ |
| 85 |
|
| char **key_strings; |
| 86 |
|
| size_t *key_lengths; |
| 87 |
|
| IV key_alloc_count; |
| 88 |
|
| }; |
| 89 |
|
| |
| 90 |
|
| /* perl api state information associated with an individual memcached_st */ |
| 91 |
|
| struct lmc_state_st { |
| 92 |
|
| memcached_st *ptr; |
| 93 |
|
| HV *hv; /* pointer back to HV (not refcntd) */ |
| 94 |
|
| IV trace_level; |
| 95 |
|
| int options; |
| 96 |
|
| memcached_return last_return; |
| 97 |
|
| int last_errno; |
| 98 |
|
| /* handy default fetch context for fetching single items */ |
| 99 |
|
| lmc_cb_context_st *cb_context; /* points to _cb_context by default */ |
| 100 |
|
| lmc_cb_context_st _cb_context; |
| 101 |
|
| }; |
| 102 |
|
| |
| 103 |
|
| static lmc_state_st * |
| 104 |
30 |
| lmc_state_new(memcached_st *ptr, HV *memc_hv) |
| 105 |
|
| { |
| 106 |
30 |
| char *trace = getenv("PERL_LIBMEMCACHED_TRACE"); |
| 107 |
|
| lmc_state_st *lmc_state; |
| 108 |
30 |
| Newz(0, lmc_state, 1, struct lmc_state_st); |
| 109 |
30 |
| lmc_state->ptr = ptr; |
| 110 |
30 |
| lmc_state->hv = memc_hv; |
| 111 |
30 |
| lmc_state->cb_context = &lmc_state->_cb_context; |
| 112 |
30 |
| lmc_state->cb_context->lmc_state = lmc_state; |
| 113 |
30 |
| lmc_state->cb_context->set_cb = newSV(0); |
| 114 |
30 |
| lmc_state->cb_context->get_cb = newSV(0); |
| 115 |
30 |
▶ | if (trace) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (trace) { |
0 |
30 |
30 |
|
| 116 |
0 |
| lmc_state->trace_level = (IV)atoi(trace); |
| 117 |
|
| } |
| 118 |
30 |
| return lmc_state; |
| 119 |
|
| } |
| 120 |
|
| |
| 121 |
|
| |
| 122 |
|
| /* ====================================================================================== */ |
| 123 |
|
| |
| 124 |
|
| |
| 125 |
|
| static void |
| 126 |
0 |
| _prep_keys_buffer(lmc_cb_context_st *lmc_cb_context, int keys_needed) |
| 127 |
|
| { |
| 128 |
0 |
| IV trace_level = lmc_cb_context->lmc_state->trace_level; |
| 129 |
0 |
▶ | if (keys_needed <= lmc_cb_context->key_alloc_count) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (keys_needed <= lmc_cb_context->key_alloc_count) { |
0 |
0 |
0 |
|
| 130 |
0 |
▶ | if (trace_level >= 9) |
Branch: 1 branch
| Branch | True | False | Total |
| if (trace_level >= 9) |
0 |
0 |
0 |
|
| 131 |
0 |
| warn("reusing keys buffer"); |
| 132 |
0 |
| return; |
| 133 |
|
| } |
| 134 |
0 |
▶ | if (!lmc_cb_context->key_strings) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!lmc_cb_context->key_strings) { |
0 |
0 |
0 |
|
| 135 |
0 |
| Newx(lmc_cb_context->key_strings, keys_needed, char *); |
| 136 |
0 |
| Newx(lmc_cb_context->key_lengths, keys_needed, size_t); |
| 137 |
0 |
▶ | if (trace_level >= 3) |
Branch: 1 branch
| Branch | True | False | Total |
| if (trace_level >= 3) |
0 |
0 |
0 |
|
| 138 |
0 |
| warn("new keys buffer"); |
| 139 |
|
| } |
| 140 |
|
| else { |
| 141 |
0 |
| keys_needed *= 1.2; |
| 142 |
0 |
| Renew(lmc_cb_context->key_strings, keys_needed, char *); |
| 143 |
0 |
| Renew(lmc_cb_context->key_lengths, keys_needed, size_t); |
| 144 |
0 |
▶ | if (trace_level >= 3) |
Branch: 1 branch
| Branch | True | False | Total |
| if (trace_level >= 3) |
0 |
0 |
0 |
|
| 145 |
0 |
| warn("growing keys buffer %d->%d", (int)lmc_cb_context->key_alloc_count, keys_needed); |
| 146 |
|
| } |
| 147 |
0 |
| lmc_cb_context->key_alloc_count = keys_needed; |
| 148 |
|
| } |
| 149 |
|
| |
| 150 |
|
| |
| 151 |
|
| static memcached_return |
| 152 |
0 |
| _prep_keys_lengths(memcached_st *ptr, SV *keys_rv, char ***out_keys, size_t **out_key_length, unsigned int *out_number_of_keys) |
| 153 |
|
| { |
| 154 |
|
| SV *keys_sv; |
| 155 |
|
| unsigned int number_of_keys; |
| 156 |
|
| char **keys; |
| 157 |
|
| size_t *key_length; |
| 158 |
0 |
| int i = 0; |
| 159 |
|
| |
| 160 |
0 |
| lmc_state_st *lmc_state = LMC_STATE_FROM_PTR(ptr); |
| 161 |
0 |
| lmc_cb_context_st *lmc_cb_context = lmc_state->cb_context; |
| 162 |
|
| |
| 163 |
0 |
▶ | if (!SvROK(keys_rv)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvROK(keys_rv)) |
0 |
0 |
0 |
|
| 164 |
0 |
| return MEMCACHED_NO_KEY_PROVIDED; |
| 165 |
0 |
| keys_sv = SvRV(keys_rv); |
| 166 |
0 |
▶ | if (SvRMAGICAL(keys_rv)) /* disallow tied arrays for now */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvRMAGICAL(keys_rv)) /* disallow tied arrays for now */ |
0 |
0 |
0 |
|
| 167 |
0 |
| return MEMCACHED_NO_KEY_PROVIDED; |
| 168 |
|
| |
| 169 |
0 |
▶ | if (SvTYPE(keys_sv) == SVt_PVAV) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvTYPE(keys_sv) == SVt_PVAV) { |
0 |
0 |
0 |
|
| 170 |
0 |
| number_of_keys = AvFILL(keys_sv)+1; |
| 171 |
0 |
▶ | if (number_of_keys > lmc_cb_context->key_alloc_count) |
Branch: 1 branch
| Branch | True | False | Total |
| if (number_of_keys > lmc_cb_context->key_alloc_count) |
0 |
0 |
0 |
|
| 172 |
0 |
| _prep_keys_buffer(lmc_cb_context, number_of_keys); |
| 173 |
0 |
| keys = lmc_cb_context->key_strings; |
| 174 |
0 |
| key_length = lmc_cb_context->key_lengths; |
| 175 |
0 |
▶ | for (i = 0; i < number_of_keys; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < number_of_keys; i++) { |
0 |
0 |
0 |
|
| 176 |
0 |
| keys[i] = SvPV(AvARRAY(keys_sv)[i], key_length[i]); |
| 177 |
|
| } |
| 178 |
|
| } |
| 179 |
0 |
▶ | else if (SvTYPE(keys_sv) == SVt_PVHV) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (SvTYPE(keys_sv) == SVt_PVHV) { |
0 |
0 |
0 |
|
| 180 |
|
| HE *he; |
| 181 |
|
| I32 retlen; |
| 182 |
0 |
| hv_iterinit((HV*)keys_sv); |
| 183 |
0 |
▶ | number_of_keys = HvKEYS(keys_sv); |
Branch: 1 branch
| Branch | True | False | Total |
| number_of_keys = HvKEYS(keys_sv); |
0 |
0 |
0 |
|
| 184 |
0 |
▶ | if (number_of_keys > lmc_cb_context->key_alloc_count) |
Branch: 1 branch
| Branch | True | False | Total |
| if (number_of_keys > lmc_cb_context->key_alloc_count) |
0 |
0 |
0 |
|
| 185 |
0 |
| _prep_keys_buffer(lmc_cb_context, number_of_keys); |
| 186 |
0 |
| keys = lmc_cb_context->key_strings; |
| 187 |
0 |
| key_length = lmc_cb_context->key_lengths; |
| 188 |
0 |
▶ | while ( (he = hv_iternext((HV*)keys_sv)) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ( (he = hv_iternext((HV*)keys_sv)) ) { |
0 |
0 |
0 |
|
| 189 |
0 |
| keys[i] = hv_iterkey(he, &retlen); |
| 190 |
0 |
| key_length[i++] = retlen; |
| 191 |
|
| } |
| 192 |
|
| } |
| 193 |
|
| else { |
| 194 |
0 |
| return MEMCACHED_NO_KEY_PROVIDED; |
| 195 |
|
| } |
| 196 |
0 |
| *out_number_of_keys = number_of_keys; |
| 197 |
0 |
| *out_keys = keys; |
| 198 |
0 |
| *out_key_length = key_length; |
| 199 |
0 |
| return MEMCACHED_SUCCESS; |
| 200 |
|
| } |
| 201 |
|
| |
| 202 |
|
| |
| 203 |
|
| /* ====================================================================================== */ |
| 204 |
|
| |
| 205 |
|
| /* --- callbacks for memcached_fetch_execute --- |
| 206 |
|
| */ |
| 207 |
|
| |
| 208 |
|
| static unsigned int |
| 209 |
0 |
| _cb_prep_store_into_sv_of_hv(memcached_st *ptr, memcached_result_st *result, void *context) |
| 210 |
|
| { |
| 211 |
|
| /* Set dest_sv to the appropriate sv in dest_hv */ |
| 212 |
|
| /* Called before _cb_store_into_sv when fetching into a hash */ |
| 213 |
0 |
| lmc_cb_context_st *lmc_cb_context = context; |
| 214 |
0 |
| SV **svp = hv_fetch( lmc_cb_context->dest_hv, memcached_result_key_value(result), memcached_result_key_length(result), 1); |
| 215 |
0 |
| lmc_cb_context->dest_sv = *svp; |
| 216 |
0 |
| return 0; |
| 217 |
|
| } |
| 218 |
|
| |
| 219 |
|
| static unsigned int |
| 220 |
0 |
| _cb_store_into_sv(memcached_st *ptr, memcached_result_st *result, void *context) |
| 221 |
|
| { |
| 222 |
|
| /* Store result value and flags into places specified by lmc_cb_context */ |
| 223 |
|
| /* This is the 'core' fetch callback. Increments result_count. */ |
| 224 |
0 |
| lmc_cb_context_st *lmc_cb_context = context; |
| 225 |
0 |
| ++lmc_cb_context->result_count; |
| 226 |
0 |
| *lmc_cb_context->flags_ptr = memcached_result_flags(result); |
| 227 |
0 |
| sv_setpvn(lmc_cb_context->dest_sv, memcached_result_value(result), memcached_result_length(result)); |
| 228 |
0 |
▶ | if (lmc_cb_context->lmc_state->trace_level >= 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (lmc_cb_context->lmc_state->trace_level >= 2) |
0 |
0 |
0 |
|
| 229 |
0 |
| warn("fetched %s (value len %d, flags %lu)\n", |
| 230 |
|
| memcached_result_key_value(result), (int) memcached_result_length(result), (long unsigned int)memcached_result_flags(result)); |
| 231 |
0 |
| return 0; |
| 232 |
|
| } |
| 233 |
|
| |
| 234 |
|
| |
| 235 |
|
| /* XXX - Notes: |
| 236 |
|
| * Perl callbacks are called as |
| 237 |
|
| * |
| 238 |
|
| * sub { |
| 239 |
|
| * my ($key, $flags) = @_; # with $_ containing the value |
| 240 |
|
| * } |
| 241 |
|
| * |
| 242 |
|
| * Modifications to $_ (value) and $_[1] (flags) propagate to other callbacks, |
| 243 |
|
| * and thus to libmemcached. |
| 244 |
|
| * Callbacks can't recurse within the same $memc at the moment. |
| 245 |
|
| */ |
| 246 |
|
| static unsigned int |
| 247 |
0 |
| _cb_fire_perl_cb(lmc_cb_context_st *lmc_cb_context, SV *callback_sv, SV *key_sv, SV *value_sv, SV *flags_sv, SV *cas_sv) |
| 248 |
|
| { |
| 249 |
|
| int items; |
| 250 |
0 |
| dSP; |
| 251 |
|
| |
| 252 |
0 |
| ENTER; |
| 253 |
0 |
| SAVETMPS; |
| 254 |
|
| |
| 255 |
0 |
| SAVE_DEFSV; /* local($_) = $value */ |
| 256 |
0 |
▶ | DEFSV = value_sv; |
Branch: 1 branch
| Branch | True | False | Total |
| DEFSV = value_sv; |
0 |
0 |
0 |
|
| 257 |
|
| |
| 258 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 259 |
0 |
▶ | EXTEND(SP, 2); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 2); |
0 |
0 |
0 |
|
| 260 |
0 |
| PUSHs(key_sv); |
| 261 |
0 |
| PUSHs(flags_sv); |
| 262 |
0 |
▶ | if (cas_sv) |
Branch: 1 branch
| Branch | True | False | Total |
| if (cas_sv) |
0 |
0 |
0 |
|
| 263 |
0 |
| PUSHs(cas_sv); |
| 264 |
0 |
| PUTBACK; |
| 265 |
|
| |
| 266 |
0 |
| items = call_sv(callback_sv, G_ARRAY); |
| 267 |
0 |
| SPAGAIN; |
| 268 |
|
| |
| 269 |
0 |
▶ | if (items) /* may use returned items for signalling later */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (items) /* may use returned items for signalling later */ |
0 |
0 |
0 |
|
| 270 |
0 |
| croak("callback returned non-empty list"); |
| 271 |
|
| |
| 272 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 273 |
0 |
| LEAVE; |
| 274 |
0 |
| return 0; |
| 275 |
|
| } |
| 276 |
|
| |
| 277 |
|
| |
| 278 |
|
| static unsigned int |
| 279 |
0 |
| _cb_fire_perl_set_cb(memcached_st *ptr, SV *key_sv, SV *value_sv, SV *flags_sv) |
| 280 |
|
| { |
| 281 |
|
| /* XXX note different api to _cb_fire_perl_get_cb */ |
| 282 |
0 |
| lmc_state_st *lmc_state = LMC_STATE_FROM_PTR(ptr); |
| 283 |
0 |
| lmc_cb_context_st *lmc_cb_context = lmc_state->cb_context; |
| 284 |
|
| unsigned int status; |
| 285 |
|
| |
| 286 |
0 |
▶ | if (!SvOK(lmc_cb_context->set_cb)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(lmc_cb_context->set_cb)) |
0 |
0 |
0 |
|
| 287 |
0 |
| return 0; |
| 288 |
|
| |
| 289 |
0 |
| status = _cb_fire_perl_cb(lmc_cb_context, lmc_cb_context->set_cb, key_sv, value_sv, flags_sv, NULL); |
| 290 |
0 |
| return status; |
| 291 |
|
| } |
| 292 |
|
| |
| 293 |
|
| static unsigned int |
| 294 |
0 |
| _cb_fire_perl_get_cb(memcached_st *ptr, memcached_result_st *result, void *context) |
| 295 |
|
| { |
| 296 |
|
| /* designed to be called via memcached_fetch_execute() */ |
| 297 |
0 |
| lmc_cb_context_st *lmc_cb_context = context; |
| 298 |
|
| SV *key_sv, *value_sv, *flags_sv, *cas_sv; |
| 299 |
|
| unsigned int status; |
| 300 |
|
| |
| 301 |
0 |
▶ | if (!SvOK(lmc_cb_context->get_cb)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(lmc_cb_context->get_cb)) |
0 |
0 |
0 |
|
| 302 |
0 |
| return 0; |
| 303 |
|
| |
| 304 |
|
| /* these SVs may get cached inside lmc_cb_context_st and reused across calls */ |
| 305 |
|
| /* which would save the create,mortalize,destroy costs for each invocation */ |
| 306 |
0 |
| key_sv = sv_2mortal(newSVpv(memcached_result_key_value(result), memcached_result_key_length(result))); |
| 307 |
0 |
| value_sv = lmc_cb_context->dest_sv; |
| 308 |
0 |
| flags_sv = sv_2mortal(newSVuv(*lmc_cb_context->flags_ptr)); |
| 309 |
0 |
▶ | if (memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_SUPPORT_CAS)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_SUPPORT_CAS)) { |
0 |
0 |
0 |
|
| 310 |
0 |
| uint64_t cas = memcached_result_cas(result); |
| 311 |
0 |
| warn("cas not fully supported"); /* if sizeof UV < sizeof uint64_t */ |
| 312 |
0 |
| cas_sv = sv_2mortal(newSVuv(cas)); |
| 313 |
|
| } |
| 314 |
0 |
| else cas_sv = NULL; |
| 315 |
|
| |
| 316 |
0 |
| SvREADONLY_on(key_sv); /* just to be sure for now, may allow later */ |
| 317 |
|
| |
| 318 |
0 |
| status = _cb_fire_perl_cb(lmc_cb_context, lmc_cb_context->get_cb, key_sv, value_sv, flags_sv, cas_sv); |
| 319 |
|
| /* recover potentially modified values */ |
| 320 |
0 |
| *lmc_cb_context->flags_ptr = SvUV(flags_sv); |
| 321 |
|
| |
| 322 |
0 |
| return status; |
| 323 |
|
| } |
| 324 |
|
| |
| 325 |
|
| typedef unsigned int (*memcached_callback_fp)(memcached_st *ptr, memcached_result_st *result, void *context); |
| 326 |
|
| |
| 327 |
|
| memcached_callback_fp lmc_store_hv_get[3][3] = { |
| 328 |
|
| { _cb_prep_store_into_sv_of_hv, _cb_store_into_sv, }, |
| 329 |
|
| { _cb_prep_store_into_sv_of_hv, _cb_store_into_sv, _cb_fire_perl_get_cb, }, |
| 330 |
|
| }; |
| 331 |
|
| memcached_callback_fp lmc_store_sv_get[3][3] = { |
| 332 |
|
| { _cb_store_into_sv, }, |
| 333 |
|
| { _cb_store_into_sv, _cb_fire_perl_get_cb, }, |
| 334 |
|
| }; |
| 335 |
|
| |
| 336 |
|
| |
| 337 |
|
| /* ====================================================================================== */ |
| 338 |
|
| |
| 339 |
|
| |
| 340 |
|
| static SV * |
| 341 |
0 |
| _fetch_one_sv(memcached_st *ptr, lmc_data_flags_t *flags_ptr, memcached_return *error_ptr) |
| 342 |
|
| { |
| 343 |
0 |
| lmc_cb_context_st *lmc_cb_context = LMC_STATE_FROM_PTR(ptr)->cb_context; |
| 344 |
|
| |
| 345 |
0 |
| int callback_ix = 0; |
| 346 |
|
| memcached_callback_fp callbacks[5]; |
| 347 |
0 |
| callbacks[callback_ix++] = _cb_store_into_sv; |
| 348 |
0 |
▶ | if (SvOK(lmc_cb_context->get_cb)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(lmc_cb_context->get_cb)) |
0 |
0 |
0 |
|
| 349 |
0 |
| callbacks[callback_ix++] = _cb_fire_perl_get_cb; |
| 350 |
0 |
| callbacks[callback_ix ] = NULL; |
| 351 |
|
| |
| 352 |
0 |
▶ | if (*error_ptr != MEMCACHED_SUCCESS) /* did preceeding mget succeed */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (*error_ptr != MEMCACHED_SUCCESS) /* did preceeding mget succeed */ |
0 |
0 |
0 |
|
| 353 |
0 |
| return &PL_sv_undef; |
| 354 |
|
| |
| 355 |
0 |
| lmc_cb_context->dest_sv = newSV(0); |
| 356 |
0 |
| lmc_cb_context->flags_ptr = flags_ptr; |
| 357 |
0 |
| lmc_cb_context->rc_ptr = error_ptr; |
| 358 |
0 |
| lmc_cb_context->result_count = 0; |
| 359 |
|
| |
| 360 |
0 |
| *error_ptr = memcached_fetch_execute(ptr, (memcached_execute_fn *)callbacks, lmc_cb_context, callback_ix); |
| 361 |
|
| |
| 362 |
0 |
▶ | if (lmc_cb_context->result_count == 0 && (*error_ptr == MEMCACHED_SUCCESS || *error_ptr == MEMCACHED_END)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (lmc_cb_context->result_count == 0 && (*error_ptr == MEMCACHED_SUCCESS || *error_ptr == MEMCACHED_END)) |
0 |
0 |
0 |
| if (lmc_cb_context->result_count == 0 && (*error_ptr == MEMCACHED_SUCCESS || *error_ptr == MEMCACHED_END)) |
0 |
0 |
0 |
| if (lmc_cb_context->result_count == 0 && (*error_ptr == MEMCACHED_SUCCESS || *error_ptr == MEMCACHED_END)) |
0 |
0 |
0 |
|
| 363 |
0 |
| *error_ptr = MEMCACHED_NOTFOUND; /* to match memcached_get behaviour */ |
| 364 |
0 |
▶ | else if (lmc_cb_context->result_count > 0 && *error_ptr == MEMCACHED_END) |
Branch: 2 branches
| Branch | True | False | Total |
| else if (lmc_cb_context->result_count > 0 && *error_ptr == MEMCACHED_END) |
0 |
0 |
0 |
| else if (lmc_cb_context->result_count > 0 && *error_ptr == MEMCACHED_END) |
0 |
0 |
0 |
|
| 365 |
0 |
| *error_ptr = MEMCACHED_SUCCESS; /* to match memcached_get behaviour */ |
| 366 |
|
| |
| 367 |
0 |
| return lmc_cb_context->dest_sv; |
| 368 |
|
| } |
| 369 |
|
| |
| 370 |
|
| |
| 371 |
|
| static memcached_return |
| 372 |
0 |
| _fetch_all_into_hashref(memcached_st *ptr, memcached_return rc, HV *dest_ref) |
| 373 |
|
| { |
| 374 |
0 |
| lmc_cb_context_st *lmc_cb_context = LMC_STATE_FROM_PTR(ptr)->cb_context; |
| 375 |
|
| lmc_data_flags_t flags; |
| 376 |
|
| |
| 377 |
0 |
| int callback_ix = 0; |
| 378 |
|
| memcached_callback_fp callbacks[5]; |
| 379 |
0 |
| callbacks[callback_ix++] = _cb_prep_store_into_sv_of_hv; |
| 380 |
0 |
| callbacks[callback_ix++] = _cb_store_into_sv; |
| 381 |
0 |
▶ | if (SvOK(lmc_cb_context->get_cb)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(lmc_cb_context->get_cb)) |
0 |
0 |
0 |
|
| 382 |
0 |
| callbacks[callback_ix++] = _cb_fire_perl_get_cb; |
| 383 |
0 |
| callbacks[callback_ix ] = NULL; |
| 384 |
|
| |
| 385 |
0 |
| lmc_cb_context->dest_hv = dest_ref; |
| 386 |
0 |
| lmc_cb_context->flags_ptr = &flags; /* local, not safe for caller */ |
| 387 |
0 |
| lmc_cb_context->rc_ptr = &rc; /* local, not safe for caller */ |
| 388 |
0 |
| lmc_cb_context->result_count = 0; |
| 389 |
|
| |
| 390 |
|
| /* rc is the return code from the preceeding mget */ |
| 391 |
0 |
▶ | if (!LMC_RETURN_OK(rc)) { |
Branch: 5 branches
| Branch | True | False | Total |
| if (!LMC_RETURN_OK(rc)) { |
0 |
0 |
0 |
| if (!LMC_RETURN_OK(rc)) { |
0 |
0 |
0 |
| if (!LMC_RETURN_OK(rc)) { |
0 |
0 |
0 |
| if (!LMC_RETURN_OK(rc)) { |
0 |
0 |
0 |
| if (!LMC_RETURN_OK(rc)) { |
0 |
0 |
0 |
|
| 392 |
0 |
▶ | if (rc == MEMCACHED_INVALID_ARGUMENTS) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc == MEMCACHED_INVALID_ARGUMENTS) { |
0 |
0 |
0 |
|
| 393 |
|
| /* when number_of_keys==0 memcached_mget returns MEMCACHED_INVALID_ARGUMENTS |
| 394 |
|
| * which we'd normally translate into a false return value |
| 395 |
|
| * but that's not really appropriate here |
| 396 |
|
| */ |
| 397 |
0 |
| return MEMCACHED_SUCCESS; |
| 398 |
|
| } |
| 399 |
0 |
| return rc; |
| 400 |
|
| } |
| 401 |
|
| |
| 402 |
0 |
| rc = memcached_fetch_execute(ptr, (memcached_execute_fn *)callbacks, (void *)lmc_cb_context, callback_ix); |
| 403 |
0 |
▶ | if (rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_SUCCESS) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_SUCCESS) { |
0 |
0 |
0 |
| if (rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_SUCCESS) { |
0 |
0 |
0 |
|
| 404 |
0 |
| return MEMCACHED_SUCCESS; /* This is a success, no matter what */ |
| 405 |
|
| } |
| 406 |
0 |
| return rc; |
| 407 |
|
| } |
| 408 |
|
| |
| 409 |
|
| |
| 410 |
|
| static memcached_return_t |
| 411 |
0 |
| _walk_stats_cb(const memcached_instance_st *instance, |
| 412 |
|
| const char *key, size_t key_length, |
| 413 |
|
| const char *value, size_t value_length, |
| 414 |
|
| void *cb) |
| 415 |
|
| { |
| 416 |
0 |
| dSP; |
| 417 |
|
| int items; |
| 418 |
|
| |
| 419 |
|
| /* callback is called with key, value, hostname, typename */ |
| 420 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 421 |
0 |
▶ | XPUSHs(sv_2mortal(newSVpv(key, key_length))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv(key, key_length))); |
0 |
0 |
0 |
|
| 422 |
0 |
▶ | XPUSHs(sv_2mortal(newSVpv(value, value_length))); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpv(value, value_length))); |
0 |
0 |
0 |
|
| 423 |
0 |
▶ | XPUSHs(sv_2mortal(newSVpvf("%s:%d", |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(sv_2mortal(newSVpvf("%s:%d", |
0 |
0 |
0 |
|
| 424 |
|
| memcached_server_name(instance), memcached_server_port(instance)))); |
| 425 |
0 |
▶ | XPUSHs(DEFSV); /* XXX deprecated $stats_arg in $_ */ |
Branch: 2 branches
| Branch | True | False | Total |
| XPUSHs(DEFSV); /* XXX deprecated $stats_arg in $_ */ |
0 |
0 |
0 |
| XPUSHs(DEFSV); /* XXX deprecated $stats_arg in $_ */ |
0 |
0 |
0 |
|
| 426 |
0 |
| PUTBACK; |
| 427 |
0 |
| items = call_sv((SV*)cb, G_ARRAY); |
| 428 |
0 |
| SPAGAIN; |
| 429 |
0 |
▶ | if (items) /* XXX may use returned items for signalling later */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (items) /* XXX may use returned items for signalling later */ |
0 |
0 |
0 |
|
| 430 |
0 |
| croak("walk_stats callback returned non-empty list"); |
| 431 |
|
| |
| 432 |
0 |
| return MEMCACHED_SUCCESS; |
| 433 |
|
| } |
| 434 |
|
| |
| 435 |
|
| |
| 436 |
|
| |
| 437 |
|
| MODULE=Memcached::libmemcached PACKAGE=Memcached::libmemcached |
| 438 |
|
| |
| 439 |
|
| PROTOTYPES: DISABLED |
| 440 |
|
| |
| 441 |
|
| INCLUDE: const-xs.inc |
| 442 |
|
| |
| 443 |
|
| |
| 444 |
|
| =head2 Functions For Managing libmemcached Objects |
| 445 |
|
| |
| 446 |
|
| =cut |
| 447 |
|
| |
| 448 |
|
| Memcached__libmemcached |
| 449 |
|
| memcached_create(Memcached__libmemcached ptr=NULL) |
| 450 |
|
| ALIAS: |
| 451 |
|
| new = 1 |
| 452 |
|
| PREINIT: |
| 453 |
29 |
▶ | SV *class_sv = (items >= 1) ? ST(0) : NULL; |
Branch: 2 branches
| Branch | True | False | Total |
| SV *class_sv = (items >= 1) ? ST(0) : NULL; |
4 |
25 |
29 |
| SV *class_sv = (items >= 1) ? ST(0) : NULL; |
25 |
4 |
29 |
|
| 454 |
|
| INIT: |
| 455 |
29 |
| ptr = NULL; /* force null even if arg provided */ |
| 456 |
|
| PERL_UNUSED_VAR(ix); |
| 457 |
|
| |
| 458 |
|
| |
| 459 |
|
| Memcached__libmemcached |
| 460 |
|
| memcached_clone(Memcached__libmemcached clone, Memcached__libmemcached source) |
| 461 |
|
| PREINIT: |
| 462 |
1 |
▶ | SV *class_sv = (items >= 1) ? ST(0) : NULL; |
Branch: 2 branches
| Branch | True | False | Total |
| SV *class_sv = (items >= 1) ? ST(0) : NULL; |
1 |
0 |
1 |
| SV *class_sv = (items >= 1) ? ST(0) : NULL; |
1 |
0 |
1 |
|
| 463 |
|
| INIT: |
| 464 |
1 |
| clone = NULL; /* force null even if arg provided */ |
| 465 |
|
| |
| 466 |
|
| |
| 467 |
|
| unsigned int |
| 468 |
|
| memcached_server_count(Memcached__libmemcached ptr) |
| 469 |
|
| |
| 470 |
|
| memcached_return |
| 471 |
|
| memcached_server_add(Memcached__libmemcached ptr, char *hostname, unsigned int port=0) |
| 472 |
|
| |
| 473 |
|
| memcached_return |
| 474 |
|
| memcached_server_add_with_weight(Memcached__libmemcached ptr, char *hostname, unsigned int port=0, unsigned int weight) |
| 475 |
|
| |
| 476 |
|
| memcached_return |
| 477 |
|
| memcached_server_add_unix_socket(Memcached__libmemcached ptr, char *socket) |
| 478 |
|
| |
| 479 |
|
| memcached_return |
| 480 |
|
| memcached_server_add_unix_socket_with_weight(Memcached__libmemcached ptr, char *socket, unsigned int weight) |
| 481 |
|
| |
| 482 |
|
| void |
| 483 |
|
| memcached_free(Memcached__libmemcached ptr) |
| 484 |
|
| INIT: |
| 485 |
4 |
▶ | if (!ptr) /* garbage or already freed this sv */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (!ptr) /* garbage or already freed this sv */ |
1 |
3 |
4 |
|
| 486 |
1 |
| XSRETURN_EMPTY; |
| 487 |
|
| POSTCALL: |
| 488 |
3 |
| LMC_STATE_FROM_PTR(ptr)->ptr = NULL; |
| 489 |
|
| |
| 490 |
|
| void |
| 491 |
|
| DESTROY(SV *sv) |
| 492 |
|
| PPCODE: |
| 493 |
|
| lmc_state_st *lmc_state; |
| 494 |
|
| lmc_cb_context_st *lmc_cb_context; |
| 495 |
|
| |
| 496 |
30 |
| lmc_state = (lmc_state_st*)LMC_STATE_FROM_SV(sv); |
| 497 |
30 |
▶ | if (lmc_state->trace_level >= 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (lmc_state->trace_level >= 2) { |
0 |
30 |
30 |
|
| 498 |
0 |
| warn("DESTROY sv %p, state %p, ptr %p", SvRV(sv), lmc_state, lmc_state->ptr); |
| 499 |
0 |
▶ | if (lmc_state->trace_level >= 9) |
Branch: 1 branch
| Branch | True | False | Total |
| if (lmc_state->trace_level >= 9) |
0 |
0 |
0 |
|
| 500 |
0 |
| sv_dump(sv); |
| 501 |
|
| } |
| 502 |
30 |
▶ | if (lmc_state->ptr) |
Branch: 1 branch
| Branch | True | False | Total |
| if (lmc_state->ptr) |
27 |
3 |
30 |
|
| 503 |
27 |
| memcached_free(lmc_state->ptr); |
| 504 |
|
| |
| 505 |
30 |
| lmc_cb_context = lmc_state->cb_context; |
| 506 |
30 |
| sv_free(lmc_cb_context->get_cb); |
| 507 |
30 |
| sv_free(lmc_cb_context->set_cb); |
| 508 |
30 |
| Safefree(lmc_cb_context->key_strings); |
| 509 |
30 |
| Safefree(lmc_cb_context->key_lengths); |
| 510 |
|
| |
| 511 |
30 |
| sv_unmagic(SvRV(sv), '~'); /* disconnect lmc_state from HV */ |
| 512 |
30 |
| Safefree(lmc_state); |
| 513 |
|
| |
| 514 |
|
| UV |
| 515 |
|
| memcached_behavior_get(Memcached__libmemcached ptr, memcached_behavior flag) |
| 516 |
|
| |
| 517 |
|
| memcached_return |
| 518 |
|
| memcached_behavior_set(Memcached__libmemcached ptr, memcached_behavior flag, uint64_t data) |
| 519 |
|
| |
| 520 |
|
| memcached_return |
| 521 |
|
| memcached_callback_set(Memcached__libmemcached ptr, memcached_callback flag, SV *data) |
| 522 |
|
| CODE: |
| 523 |
|
| /* we only allow setting of known-safe flags */ |
| 524 |
0 |
▶ | switch (flag) { |
Branch: 1 branch
| Branch | True | False | Total |
| switch (flag) { |
0 |
0 |
0 |
|
| 525 |
0 |
| case MEMCACHED_CALLBACK_PREFIX_KEY: |
| 526 |
0 |
| RETVAL = memcached_callback_set(ptr, flag, SvPV_nolen(data)); |
| 527 |
0 |
| break; |
| 528 |
0 |
| default: |
| 529 |
0 |
| RETVAL = MEMCACHED_FAILURE; |
| 530 |
0 |
| break; |
| 531 |
|
| } |
| 532 |
|
| OUTPUT: |
| 533 |
|
| RETVAL |
| 534 |
|
| |
| 535 |
|
| SV * |
| 536 |
|
| memcached_callback_get(Memcached__libmemcached ptr, memcached_callback flag, IN_OUT memcached_return ret=NO_INIT) |
| 537 |
|
| PREINIT: |
| 538 |
0 |
| void *data = NULL; |
| 539 |
|
| CODE: |
| 540 |
0 |
| RETVAL = &PL_sv_undef; |
| 541 |
|
| /* we only allow setting of known-safe flags */ |
| 542 |
0 |
▶ | switch (flag) { |
Branch: 1 branch
| Branch | True | False | Total |
| switch (flag) { |
0 |
0 |
0 |
|
| 543 |
0 |
| case MEMCACHED_CALLBACK_PREFIX_KEY: |
| 544 |
0 |
| data = memcached_callback_get(ptr, flag, &ret); |
| 545 |
|
| /* libmemcached treats empty prefix as an error */ |
| 546 |
|
| /* we treat it more pragmatically */ |
| 547 |
0 |
▶ | RETVAL = newSVpv((data) ? data : "", 0); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = newSVpv((data) ? data : "", 0); |
0 |
0 |
0 |
|
| 548 |
0 |
| break; |
| 549 |
0 |
| default: |
| 550 |
0 |
| ret = MEMCACHED_FAILURE; |
| 551 |
0 |
| break; |
| 552 |
|
| } |
| 553 |
|
| OUTPUT: |
| 554 |
|
| RETVAL |
| 555 |
|
| |
| 556 |
|
| |
| 557 |
|
| =head2 Functions for Setting Values in memcached |
| 558 |
|
| |
| 559 |
|
| =cut |
| 560 |
|
| |
| 561 |
|
| memcached_return |
| 562 |
|
| memcached_set(Memcached__libmemcached ptr, \ |
| 563 |
|
| lmc_key key, size_t length(key), \ |
| 564 |
|
| lmc_value value, size_t length(value), \ |
| 565 |
|
| lmc_expiration expiration= 0, lmc_data_flags_t flags= 0) |
| 566 |
|
| |
| 567 |
|
| memcached_return |
| 568 |
|
| memcached_set_by_key(Memcached__libmemcached ptr, \ |
| 569 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 570 |
|
| lmc_key key, size_t length(key), \ |
| 571 |
|
| lmc_value value, size_t length(value), \ |
| 572 |
|
| lmc_expiration expiration=0, lmc_data_flags_t flags=0) |
| 573 |
|
| |
| 574 |
|
| memcached_return |
| 575 |
|
| memcached_add (Memcached__libmemcached ptr, \ |
| 576 |
|
| lmc_key key, size_t length(key), \ |
| 577 |
|
| lmc_value value, size_t length(value), \ |
| 578 |
|
| lmc_expiration expiration= 0, lmc_data_flags_t flags=0) |
| 579 |
|
| |
| 580 |
|
| memcached_return |
| 581 |
|
| memcached_add_by_key(Memcached__libmemcached ptr, \ |
| 582 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 583 |
|
| lmc_key key, size_t length(key), \ |
| 584 |
|
| lmc_value value, size_t length(value), \ |
| 585 |
|
| lmc_expiration expiration=0, lmc_data_flags_t flags=0) |
| 586 |
|
| |
| 587 |
|
| memcached_return |
| 588 |
|
| memcached_append(Memcached__libmemcached ptr, \ |
| 589 |
|
| lmc_key key, size_t length(key),\ |
| 590 |
|
| lmc_value value, size_t length(value),\ |
| 591 |
|
| lmc_expiration expiration= 0, lmc_data_flags_t flags=0) |
| 592 |
|
| |
| 593 |
|
| memcached_return |
| 594 |
|
| memcached_append_by_key(Memcached__libmemcached ptr, \ |
| 595 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 596 |
|
| lmc_key key, size_t length(key), \ |
| 597 |
|
| lmc_value value, size_t length(value), \ |
| 598 |
|
| lmc_expiration expiration=0, lmc_data_flags_t flags=0) |
| 599 |
|
| |
| 600 |
|
| memcached_return |
| 601 |
|
| memcached_prepend(Memcached__libmemcached ptr, \ |
| 602 |
|
| lmc_key key, size_t length(key), \ |
| 603 |
|
| lmc_value value, size_t length(value), \ |
| 604 |
|
| lmc_expiration expiration= 0, lmc_data_flags_t flags=0) |
| 605 |
|
| |
| 606 |
|
| memcached_return |
| 607 |
|
| memcached_prepend_by_key(Memcached__libmemcached ptr, \ |
| 608 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 609 |
|
| lmc_key key, size_t length(key), \ |
| 610 |
|
| lmc_value value, size_t length(value), \ |
| 611 |
|
| lmc_expiration expiration=0, lmc_data_flags_t flags=0) |
| 612 |
|
| |
| 613 |
|
| memcached_return |
| 614 |
|
| memcached_replace(Memcached__libmemcached ptr, \ |
| 615 |
|
| lmc_key key, size_t length(key), \ |
| 616 |
|
| lmc_value value, size_t length(value), \ |
| 617 |
|
| lmc_expiration expiration= 0, lmc_data_flags_t flags=0) |
| 618 |
|
| |
| 619 |
|
| memcached_return |
| 620 |
|
| memcached_replace_by_key(Memcached__libmemcached ptr, \ |
| 621 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 622 |
|
| lmc_key key, size_t length(key), \ |
| 623 |
|
| lmc_value value, size_t length(value), \ |
| 624 |
|
| lmc_expiration expiration=0, lmc_data_flags_t flags=0) |
| 625 |
|
| |
| 626 |
|
| memcached_return |
| 627 |
|
| memcached_cas(Memcached__libmemcached ptr, \ |
| 628 |
|
| lmc_key key, size_t length(key), \ |
| 629 |
|
| lmc_value value, size_t length(value), \ |
| 630 |
|
| lmc_expiration expiration= 0, lmc_data_flags_t flags=0, uint64_t cas) |
| 631 |
|
| |
| 632 |
|
| memcached_return |
| 633 |
|
| memcached_cas_by_key(Memcached__libmemcached ptr, \ |
| 634 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 635 |
|
| lmc_key key, size_t length(key), \ |
| 636 |
|
| lmc_value value, size_t length(value), \ |
| 637 |
|
| lmc_expiration expiration= 0, lmc_data_flags_t flags=0, uint64_t cas) |
| 638 |
|
| |
| 639 |
|
| |
| 640 |
|
| =head2 Functions for Incrementing and Decrementing Values from memcached |
| 641 |
|
| |
| 642 |
|
| =cut |
| 643 |
|
| |
| 644 |
|
| memcached_return |
| 645 |
|
| memcached_increment(Memcached__libmemcached ptr, \ |
| 646 |
|
| lmc_key key, size_t length(key), \ |
| 647 |
|
| unsigned int offset, IN_OUT uint64_t value=NO_INIT) |
| 648 |
|
| |
| 649 |
|
| memcached_return |
| 650 |
|
| memcached_decrement(Memcached__libmemcached ptr, \ |
| 651 |
|
| lmc_key key, size_t length(key), \ |
| 652 |
|
| unsigned int offset, IN_OUT uint64_t value=NO_INIT) |
| 653 |
|
| |
| 654 |
|
| memcached_return |
| 655 |
|
| memcached_increment_by_key(Memcached__libmemcached ptr, \ |
| 656 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 657 |
|
| lmc_key key, size_t length(key), \ |
| 658 |
|
| unsigned int offset, IN_OUT uint64_t value=NO_INIT) |
| 659 |
|
| |
| 660 |
|
| memcached_return |
| 661 |
|
| memcached_decrement_by_key(Memcached__libmemcached ptr, \ |
| 662 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 663 |
|
| lmc_key key, size_t length(key), \ |
| 664 |
|
| unsigned int offset, IN_OUT uint64_t value=NO_INIT) |
| 665 |
|
| |
| 666 |
|
| memcached_return |
| 667 |
|
| memcached_increment_with_initial (Memcached__libmemcached ptr, \ |
| 668 |
|
| lmc_key key, size_t length(key), \ |
| 669 |
|
| unsigned int offset, \ |
| 670 |
|
| uint64_t initial, \ |
| 671 |
|
| lmc_expiration expiration= 0, \ |
| 672 |
|
| IN_OUT uint64_t value=NO_INIT) |
| 673 |
|
| |
| 674 |
|
| memcached_return |
| 675 |
|
| memcached_decrement_with_initial (Memcached__libmemcached ptr, \ |
| 676 |
|
| lmc_key key, size_t length(key), \ |
| 677 |
|
| unsigned int offset, \ |
| 678 |
|
| uint64_t initial, \ |
| 679 |
|
| lmc_expiration expiration= 0, \ |
| 680 |
|
| IN_OUT uint64_t value=NO_INIT) |
| 681 |
|
| |
| 682 |
|
| memcached_return |
| 683 |
|
| memcached_increment_with_initial_by_key (Memcached__libmemcached ptr, \ |
| 684 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 685 |
|
| lmc_key key, size_t length(key), \ |
| 686 |
|
| unsigned int offset, \ |
| 687 |
|
| uint64_t initial, \ |
| 688 |
|
| lmc_expiration expiration= 0, \ |
| 689 |
|
| IN_OUT uint64_t value=NO_INIT) |
| 690 |
|
| |
| 691 |
|
| memcached_return |
| 692 |
|
| memcached_decrement_with_initial_by_key (Memcached__libmemcached ptr, \ |
| 693 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 694 |
|
| lmc_key key, size_t length(key), \ |
| 695 |
|
| unsigned int offset, \ |
| 696 |
|
| uint64_t initial, \ |
| 697 |
|
| lmc_expiration expiration= 0, \ |
| 698 |
|
| IN_OUT uint64_t value=NO_INIT) |
| 699 |
|
| |
| 700 |
|
| |
| 701 |
|
| =head2 Functions for Fetching Values from memcached |
| 702 |
|
| |
| 703 |
|
| =cut |
| 704 |
|
| |
| 705 |
|
| SV * |
| 706 |
|
| memcached_get(Memcached__libmemcached ptr, \ |
| 707 |
|
| lmc_key key, size_t length(key), \ |
| 708 |
|
| IN_OUT lmc_data_flags_t flags=0, \ |
| 709 |
|
| IN_OUT memcached_return error=0) |
| 710 |
|
| CODE: |
| 711 |
|
| /* rc is the return code from the preceeding mget */ |
| 712 |
0 |
| error = memcached_mget_by_key(ptr, NULL, 0, (const char * const*)&key, &XSauto_length_of_key, 1); |
| 713 |
0 |
| RETVAL = _fetch_one_sv(ptr, &flags, &error); |
| 714 |
|
| OUTPUT: |
| 715 |
|
| RETVAL |
| 716 |
|
| |
| 717 |
|
| |
| 718 |
|
| SV * |
| 719 |
|
| memcached_get_by_key(Memcached__libmemcached ptr, \ |
| 720 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 721 |
|
| lmc_key key, size_t length(key), \ |
| 722 |
|
| IN_OUT lmc_data_flags_t flags=0, \ |
| 723 |
|
| IN_OUT memcached_return error=0) |
| 724 |
|
| CODE: |
| 725 |
0 |
| error = memcached_mget_by_key(ptr, master_key, XSauto_length_of_master_key, (const char * const*)&key, &XSauto_length_of_key, 1); |
| 726 |
0 |
| RETVAL = _fetch_one_sv(ptr, &flags, &error); |
| 727 |
|
| OUTPUT: |
| 728 |
|
| RETVAL |
| 729 |
|
| |
| 730 |
|
| |
| 731 |
|
| memcached_return |
| 732 |
|
| memcached_mget(Memcached__libmemcached ptr, SV *keys_rv) |
| 733 |
|
| PREINIT: |
| 734 |
|
| char **keys; |
| 735 |
|
| size_t *key_length; |
| 736 |
|
| unsigned int number_of_keys; |
| 737 |
|
| CODE: |
| 738 |
0 |
▶ | if ((RETVAL = _prep_keys_lengths(ptr, keys_rv, &keys, &key_length, &number_of_keys)) == MEMCACHED_SUCCESS) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ((RETVAL = _prep_keys_lengths(ptr, keys_rv, &keys, &key_length, &number_of_keys)) == MEMCACHED_SUCCESS) { |
0 |
0 |
0 |
|
| 739 |
0 |
| RETVAL = memcached_mget(ptr, (const char * const*)keys, key_length, number_of_keys); |
| 740 |
|
| } |
| 741 |
|
| OUTPUT: |
| 742 |
|
| RETVAL |
| 743 |
|
| |
| 744 |
|
| memcached_return |
| 745 |
|
| memcached_mget_by_key(Memcached__libmemcached ptr, lmc_key master_key, size_t length(master_key), SV *keys_rv) |
| 746 |
|
| PREINIT: |
| 747 |
|
| char **keys; |
| 748 |
|
| size_t *key_length; |
| 749 |
|
| unsigned int number_of_keys; |
| 750 |
|
| CODE: |
| 751 |
0 |
▶ | if ((RETVAL = _prep_keys_lengths(ptr, keys_rv, &keys, &key_length, &number_of_keys)) == MEMCACHED_SUCCESS) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ((RETVAL = _prep_keys_lengths(ptr, keys_rv, &keys, &key_length, &number_of_keys)) == MEMCACHED_SUCCESS) { |
0 |
0 |
0 |
|
| 752 |
0 |
| RETVAL = memcached_mget_by_key(ptr, master_key, XSauto_length_of_master_key, (const char * const*)keys, key_length, number_of_keys); |
| 753 |
|
| } |
| 754 |
|
| OUTPUT: |
| 755 |
|
| RETVAL |
| 756 |
|
| |
| 757 |
|
| |
| 758 |
|
| |
| 759 |
|
| lmc_value |
| 760 |
|
| memcached_fetch(Memcached__libmemcached ptr, \ |
| 761 |
|
| OUT lmc_key key, \ |
| 762 |
|
| IN_OUT lmc_data_flags_t flags=0, \ |
| 763 |
|
| IN_OUT memcached_return error=0) |
| 764 |
|
| PREINIT: |
| 765 |
0 |
| size_t key_length=0; |
| 766 |
0 |
▶ | size_t value_length=0; |
Branch: 1 branch
| Branch | True | False | Total |
| size_t value_length=0; |
0 |
0 |
0 |
|
| 767 |
|
| char key_buffer[MEMCACHED_MAX_KEY]; |
| 768 |
|
| INIT: |
| 769 |
0 |
| key = key_buffer; |
| 770 |
|
| CODE: |
| 771 |
0 |
| RETVAL = memcached_fetch(ptr, key, &key_length, &value_length, &flags, &error); |
| 772 |
|
| OUTPUT: |
| 773 |
|
| RETVAL |
| 774 |
|
| |
| 775 |
|
| |
| 776 |
|
| |
| 777 |
|
| |
| 778 |
|
| =head2 Functions for Managing Results from memcached |
| 779 |
|
| /* |
| 780 |
|
| memcached_result_st * |
| 781 |
|
| memcached_fetch_result(Memcached__libmemcached ptr,\ |
| 782 |
|
| memcached_result_st *result,\ |
| 783 |
|
| memcached_return *error) |
| 784 |
|
| */ |
| 785 |
|
| |
| 786 |
|
| =cut |
| 787 |
|
| |
| 788 |
|
| |
| 789 |
|
| =head2 Functions for Deleting Values from memcached |
| 790 |
|
| |
| 791 |
|
| =cut |
| 792 |
|
| |
| 793 |
|
| memcached_return |
| 794 |
|
| memcached_delete(Memcached__libmemcached ptr, \ |
| 795 |
|
| lmc_key key, size_t length(key), \ |
| 796 |
|
| lmc_expiration expiration= 0) |
| 797 |
|
| |
| 798 |
|
| memcached_return |
| 799 |
|
| memcached_delete_by_key (Memcached__libmemcached ptr, \ |
| 800 |
|
| lmc_key master_key, size_t length(master_key), \ |
| 801 |
|
| lmc_key key, size_t length(key), \ |
| 802 |
|
| lmc_expiration expiration= 0) |
| 803 |
|
| |
| 804 |
|
| |
| 805 |
|
| |
| 806 |
|
| =head2 Functions for Accessing Statistics from memcached |
| 807 |
|
| |
| 808 |
|
| =cut |
| 809 |
|
| |
| 810 |
|
| |
| 811 |
|
| =head2 Miscellaneous Functions |
| 812 |
|
| |
| 813 |
|
| =cut |
| 814 |
|
| |
| 815 |
|
| memcached_return |
| 816 |
|
| memcached_verbosity(Memcached__libmemcached ptr, unsigned int verbosity) |
| 817 |
|
| |
| 818 |
|
| memcached_return |
| 819 |
|
| memcached_flush(Memcached__libmemcached ptr, lmc_expiration expiration=0) |
| 820 |
|
| |
| 821 |
|
| void |
| 822 |
|
| memcached_quit(Memcached__libmemcached ptr) |
| 823 |
|
| |
| 824 |
|
| const char * |
| 825 |
|
| memcached_strerror(Memcached__libmemcached ptr, memcached_return rc) |
| 826 |
|
| |
| 827 |
|
| const char * |
| 828 |
|
| memcached_lib_version() |
| 829 |
|
| |
| 830 |
|
| =head2 Memcached::libmemcached Methods |
| 831 |
|
| |
| 832 |
|
| =cut |
| 833 |
|
| |
| 834 |
|
| IV |
| 835 |
|
| trace_level(Memcached__libmemcached ptr, IV level = IV_MIN) |
| 836 |
|
| PREINIT: |
| 837 |
|
| lmc_state_st* lmc_state; |
| 838 |
|
| CODE: |
| 839 |
0 |
| lmc_state = LMC_STATE_FROM_PTR(ptr); |
| 840 |
0 |
▶ | RETVAL = LMC_TRACE_LEVEL_FROM_PTR(ptr); /* return previous level */ |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = LMC_TRACE_LEVEL_FROM_PTR(ptr); /* return previous level */ |
0 |
0 |
0 |
|
| 841 |
0 |
▶ | if (level != IV_MIN && lmc_state) |
Branch: 2 branches
| Branch | True | False | Total |
| if (level != IV_MIN && lmc_state) |
0 |
0 |
0 |
| if (level != IV_MIN && lmc_state) |
0 |
0 |
0 |
|
| 842 |
0 |
| lmc_state->trace_level = level; |
| 843 |
|
| OUTPUT: |
| 844 |
|
| RETVAL |
| 845 |
|
| |
| 846 |
|
| |
| 847 |
|
| SV * |
| 848 |
|
| errstr(Memcached__libmemcached ptr) |
| 849 |
|
| ALIAS: |
| 850 |
|
| memcached_errstr = 1 |
| 851 |
|
| PREINIT: |
| 852 |
|
| lmc_state_st* lmc_state; |
| 853 |
|
| CODE: |
| 854 |
23 |
▶ | if (!ptr) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!ptr) |
0 |
23 |
23 |
|
| 855 |
0 |
| XSRETURN_UNDEF; |
| 856 |
|
| PERL_UNUSED_VAR(ix); |
| 857 |
23 |
| RETVAL = newSV(0); |
| 858 |
23 |
| lmc_state = LMC_STATE_FROM_PTR(ptr); |
| 859 |
|
| /* setup return value as a dualvar with int err code and string error message */ |
| 860 |
23 |
| sv_setiv(RETVAL, lmc_state->last_return); |
| 861 |
23 |
| sv_setpv(RETVAL, memcached_strerror(ptr, lmc_state->last_return)); |
| 862 |
23 |
▶ | if (lmc_state->last_return == MEMCACHED_ERRNO) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (lmc_state->last_return == MEMCACHED_ERRNO) { |
0 |
23 |
23 |
|
| 863 |
|
| /* lmc_state->last_errno should be meaningful here but sometimes isn't */ |
| 864 |
|
| /* See https://rt.cpan.org/Ticket/Display.html?id=41299 */ |
| 865 |
0 |
▶ | sv_catpvf(RETVAL, " %s", (lmc_state->last_errno) ? strerror(lmc_state->last_errno) : "(last_errno==0!)"); |
Branch: 1 branch
| Branch | True | False | Total |
| sv_catpvf(RETVAL, " %s", (lmc_state->last_errno) ? strerror(lmc_state->last_errno) : "(last_errno==0!)"); |
0 |
0 |
0 |
|
| 866 |
|
| } |
| 867 |
23 |
| SvIOK_on(RETVAL); /* set as dualvar */ |
| 868 |
|
| OUTPUT: |
| 869 |
|
| RETVAL |
| 870 |
|
| |
| 871 |
|
| |
| 872 |
|
| SV * |
| 873 |
|
| get(Memcached__libmemcached ptr, SV *key_sv) |
| 874 |
|
| PREINIT: |
| 875 |
0 |
| char *master_key = NULL; |
| 876 |
0 |
▶ | size_t master_key_len = 0; |
Branch: 1 branch
| Branch | True | False | Total |
| size_t master_key_len = 0; |
0 |
0 |
0 |
|
| 877 |
|
| char *key; |
| 878 |
|
| size_t key_len; |
| 879 |
|
| memcached_return error; |
| 880 |
|
| uint32_t flags; |
| 881 |
|
| CODE: |
| 882 |
0 |
▶ | if (SvROK(key_sv) && SvTYPE(SvRV(key_sv)) == SVt_PVAV) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(key_sv) && SvTYPE(SvRV(key_sv)) == SVt_PVAV) { |
0 |
0 |
0 |
| if (SvROK(key_sv) && SvTYPE(SvRV(key_sv)) == SVt_PVAV) { |
0 |
0 |
0 |
|
| 883 |
0 |
| AV *av = (AV*)SvRV(key_sv); |
| 884 |
0 |
| master_key = SvPV(AvARRAY(av)[0], master_key_len); |
| 885 |
0 |
| key_sv = AvARRAY(av)[1]; |
| 886 |
0 |
| warn("get with array ref as key is deprecated"); |
| 887 |
|
| } |
| 888 |
0 |
| key = SvPV(key_sv, key_len); |
| 889 |
0 |
| error = memcached_mget_by_key(ptr, master_key, master_key_len, (const char * const*)&key, &key_len, 1); |
| 890 |
0 |
| RETVAL = _fetch_one_sv(ptr, &flags, &error); |
| 891 |
|
| OUTPUT: |
| 892 |
|
| RETVAL |
| 893 |
|
| |
| 894 |
|
| |
| 895 |
|
| void |
| 896 |
|
| get_multi(Memcached__libmemcached ptr, ...) |
| 897 |
|
| PREINIT: |
| 898 |
0 |
| HV *hv = newHV(); |
| 899 |
0 |
| SV *dest_ref = sv_2mortal(newRV_noinc((SV*)hv)); |
| 900 |
|
| char **keys; |
| 901 |
|
| size_t *key_length; |
| 902 |
0 |
▶ | unsigned int number_of_keys = --items; |
Branch: 1 branch
| Branch | True | False | Total |
| unsigned int number_of_keys = --items; |
0 |
0 |
0 |
|
| 903 |
|
| memcached_return ret; |
| 904 |
|
| lmc_cb_context_st *lmc_cb_context; |
| 905 |
|
| PPCODE: |
| 906 |
|
| /* XXX does not support keys being [ $master_key, $key ] */ |
| 907 |
0 |
| lmc_cb_context = LMC_STATE_FROM_PTR(ptr)->cb_context; |
| 908 |
|
| |
| 909 |
0 |
▶ | if (number_of_keys > lmc_cb_context->key_alloc_count) |
Branch: 1 branch
| Branch | True | False | Total |
| if (number_of_keys > lmc_cb_context->key_alloc_count) |
0 |
0 |
0 |
|
| 910 |
0 |
| _prep_keys_buffer(lmc_cb_context, number_of_keys); |
| 911 |
0 |
| keys = lmc_cb_context->key_strings; |
| 912 |
0 |
| key_length = lmc_cb_context->key_lengths; |
| 913 |
0 |
▶ | while (--items >= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (--items >= 0) { |
0 |
0 |
0 |
|
| 914 |
0 |
| keys[items] = SvPV(ST(items+1), key_length[items]); |
| 915 |
|
| } |
| 916 |
|
| |
| 917 |
0 |
| ret = memcached_mget(ptr, (const char * const*)keys, key_length, number_of_keys); |
| 918 |
0 |
| _fetch_all_into_hashref(ptr, ret, hv); |
| 919 |
0 |
▶ | if (lmc_cb_context->lmc_state->trace_level) |
Branch: 1 branch
| Branch | True | False | Total |
| if (lmc_cb_context->lmc_state->trace_level) |
0 |
0 |
0 |
|
| 920 |
0 |
| warn("get_multi of %d keys: mget %s, fetched %d", |
| 921 |
|
| number_of_keys, memcached_strerror(ptr,ret), (int)lmc_cb_context->result_count); |
| 922 |
0 |
| PUSHs(dest_ref); |
| 923 |
0 |
| XSRETURN(1); |
| 924 |
|
| |
| 925 |
|
| |
| 926 |
|
| |
| 927 |
|
| memcached_return |
| 928 |
|
| mget_into_hashref(Memcached__libmemcached ptr, SV *keys_ref, HV *dest_ref) |
| 929 |
|
| ALIAS: |
| 930 |
|
| memcached_mget_into_hashref = 1 |
| 931 |
|
| PREINIT: |
| 932 |
|
| char **keys; |
| 933 |
|
| size_t *key_length; |
| 934 |
|
| unsigned int number_of_keys; |
| 935 |
|
| CODE: |
| 936 |
|
| PERL_UNUSED_VAR(ix); |
| 937 |
0 |
▶ | if ((RETVAL = _prep_keys_lengths(ptr, keys_ref, &keys, &key_length, &number_of_keys)) == MEMCACHED_SUCCESS) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ((RETVAL = _prep_keys_lengths(ptr, keys_ref, &keys, &key_length, &number_of_keys)) == MEMCACHED_SUCCESS) { |
0 |
0 |
0 |
|
| 938 |
0 |
| RETVAL = memcached_mget(ptr, (const char * const*)keys, key_length, number_of_keys); |
| 939 |
0 |
| RETVAL = _fetch_all_into_hashref(ptr, RETVAL, dest_ref); |
| 940 |
|
| } |
| 941 |
|
| OUTPUT: |
| 942 |
|
| RETVAL |
| 943 |
|
| |
| 944 |
|
| |
| 945 |
|
| void |
| 946 |
|
| set_callback_coderefs(Memcached__libmemcached ptr, SV *set_cb, SV *get_cb) |
| 947 |
|
| ALIAS: |
| 948 |
|
| memcached_set_callback_coderefs = 1 |
| 949 |
|
| PREINIT: |
| 950 |
|
| lmc_state_st *lmc_state; |
| 951 |
|
| CODE: |
| 952 |
|
| PERL_UNUSED_VAR(ix); |
| 953 |
0 |
▶ | if (SvOK(set_cb) && !(SvROK(set_cb) && SvTYPE(SvRV(set_cb)) == SVt_PVCV)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (SvOK(set_cb) && !(SvROK(set_cb) && SvTYPE(SvRV(set_cb)) == SVt_PVCV)) |
0 |
0 |
0 |
| if (SvOK(set_cb) && !(SvROK(set_cb) && SvTYPE(SvRV(set_cb)) == SVt_PVCV)) |
0 |
0 |
0 |
| if (SvOK(set_cb) && !(SvROK(set_cb) && SvTYPE(SvRV(set_cb)) == SVt_PVCV)) |
0 |
0 |
0 |
|
| 954 |
0 |
| croak("set_cb is not a reference to a subroutine"); |
| 955 |
0 |
▶ | if (SvOK(get_cb) && !(SvROK(get_cb) && SvTYPE(SvRV(get_cb)) == SVt_PVCV)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (SvOK(get_cb) && !(SvROK(get_cb) && SvTYPE(SvRV(get_cb)) == SVt_PVCV)) |
0 |
0 |
0 |
| if (SvOK(get_cb) && !(SvROK(get_cb) && SvTYPE(SvRV(get_cb)) == SVt_PVCV)) |
0 |
0 |
0 |
| if (SvOK(get_cb) && !(SvROK(get_cb) && SvTYPE(SvRV(get_cb)) == SVt_PVCV)) |
0 |
0 |
0 |
|
| 956 |
0 |
| croak("get_cb is not a reference to a subroutine"); |
| 957 |
0 |
| lmc_state = LMC_STATE_FROM_PTR(ptr); |
| 958 |
0 |
| sv_setsv(lmc_state->cb_context->set_cb, set_cb); |
| 959 |
0 |
| sv_setsv(lmc_state->cb_context->get_cb, get_cb); |
| 960 |
|
| |
| 961 |
|
| |
| 962 |
|
| memcached_return |
| 963 |
|
| walk_stats(Memcached__libmemcached ptr, SV *stats_args, CV *cb) |
| 964 |
|
| PREINIT: |
| 965 |
|
| Memcached__libmemcached clone; |
| 966 |
|
| CODE: |
| 967 |
0 |
▶ | if (LMC_TRACE_LEVEL_FROM_PTR(ptr) >= 2) |
Branch: 2 branches
| Branch | True | False | Total |
| if (LMC_TRACE_LEVEL_FROM_PTR(ptr) >= 2) |
0 |
0 |
0 |
| if (LMC_TRACE_LEVEL_FROM_PTR(ptr) >= 2) |
0 |
0 |
0 |
|
| 968 |
0 |
▶ | warn("walk_stats(%s, %s)\n", SvPV_nolen(stats_args), SvPV_nolen((SV*)CvGV(cb))); |
Branch: 1 branch
| Branch | True | False | Total |
| warn("walk_stats(%s, %s)\n", SvPV_nolen(stats_args), SvPV_nolen((SV*)CvGV(cb))); |
0 |
0 |
0 |
|
| 969 |
|
| |
| 970 |
0 |
| clone = memcached_clone(NULL, ptr); |
| 971 |
0 |
| memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 0); |
| 972 |
|
| |
| 973 |
0 |
| ENTER; |
| 974 |
0 |
| SAVETMPS; |
| 975 |
|
| |
| 976 |
|
| /* this local($_) assignment is to aid migration from the old api */ |
| 977 |
0 |
| SAVE_DEFSV; /* local($_) */ |
| 978 |
0 |
▶ | DEFSV = sv_mortalcopy(stats_args); |
Branch: 1 branch
| Branch | True | False | Total |
| DEFSV = sv_mortalcopy(stats_args); |
0 |
0 |
0 |
|
| 979 |
|
| |
| 980 |
0 |
| RETVAL = memcached_stat_execute(clone, SvPV_nolen(stats_args), _walk_stats_cb, cb); |
| 981 |
0 |
▶ | if (!LMC_RETURN_OK(RETVAL)) { |
Branch: 5 branches
| Branch | True | False | Total |
| if (!LMC_RETURN_OK(RETVAL)) { |
0 |
0 |
0 |
| if (!LMC_RETURN_OK(RETVAL)) { |
0 |
0 |
0 |
| if (!LMC_RETURN_OK(RETVAL)) { |
0 |
0 |
0 |
| if (!LMC_RETURN_OK(RETVAL)) { |
0 |
0 |
0 |
| if (!LMC_RETURN_OK(RETVAL)) { |
0 |
0 |
0 |
|
| 982 |
0 |
▶ | LMC_RECORD_RETURN_ERR("memcached_stat_execute", ptr, RETVAL); |
Branch: 8 branches
| Branch | True | False | Total |
| LMC_RECORD_RETURN_ERR("memcached_stat_execute", ptr, RETVAL); |
0 |
0 |
0 |
| LMC_RECORD_RETURN_ERR("memcached_stat_execute", ptr, RETVAL); |
0 |
0 |
0 |
| LMC_RECORD_RETURN_ERR("memcached_stat_execute", ptr, RETVAL); |
0 |
0 |
0 |
| LMC_RECORD_RETURN_ERR("memcached_stat_execute", ptr, RETVAL); |
0 |
0 |
0 |
| LMC_RECORD_RETURN_ERR("memcached_stat_execute", ptr, RETVAL); |
0 |
0 |
0 |
| LMC_RECORD_RETURN_ERR("memcached_stat_execute", ptr, RETVAL); |
0 |
0 |
0 |
| LMC_RECORD_RETURN_ERR("memcached_stat_execute", ptr, RETVAL); |
0 |
0 |
0 |
| LMC_RECORD_RETURN_ERR("memcached_stat_execute", ptr, RETVAL); |
0 |
0 |
0 |
|
| 983 |
0 |
| LMC_STATE_FROM_PTR(ptr)->last_errno = memcached_last_error_errno(clone); |
| 984 |
0 |
| memcached_free(clone); |
| 985 |
0 |
| XSRETURN_NO; |
| 986 |
|
| } |
| 987 |
0 |
| memcached_free(clone); |
| 988 |
|
| |
| 989 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 990 |
0 |
| LEAVE; |
| 991 |
|
| OUTPUT: |
| 992 |
|
| RETVAL |
| 993 |
|
| |
| 994 |
|
| SV * get_server_for_key(Memcached__libmemcached ptr, char *key) |
| 995 |
|
| CODE: |
| 996 |
|
| memcached_return_t err; |
| 997 |
2 |
| const memcached_instance_st *sp = memcached_server_by_key(ptr, key, strlen(key), &err); |
| 998 |
2 |
▶ | if (sp == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (sp == NULL) |
0 |
2 |
2 |
|
| 999 |
0 |
| XSRETURN_UNDEF; |
| 1000 |
|
| |
| 1001 |
2 |
| RETVAL = newSVpvf("%s:%d", |
| 1002 |
|
| memcached_server_name(sp), |
| 1003 |
|
| memcached_server_port(sp) |
| 1004 |
|
| ); |
| 1005 |
|
| /* memcached_instance_free(sp); ??? */ |
| 1006 |
|
| |
| 1007 |
|
| OUTPUT: |
| 1008 |
|
| RETVAL |