in php_memcached_server.c [311:374]
protocol_binary_response_status s_get_handler (const void *cookie, const void *key, uint16_t key_len,
memcached_binary_protocol_get_response_handler response_handler)
{
protocol_binary_response_status retval = PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND;
zval zcookie, zkey, zvalue, zflags, zresult_cas;
zval params[5];
if (!MEMC_HAS_CB(MEMC_SERVER_ON_GET)) {
return retval;
}
MEMC_MAKE_ZVAL_COOKIE(zcookie, cookie);
ZVAL_COPY(¶ms[0], &zcookie);
ZVAL_COPY(¶ms[1], &zkey);
ZVAL_COPY(¶ms[2], &zvalue);
ZVAL_COPY(¶ms[3], &zflags);
ZVAL_COPY(¶ms[4], &zresult_cas);
retval = s_invoke_php_callback (&MEMC_GET_CB(MEMC_SERVER_ON_GET), params, 5);
/* Succeeded in getting the key */
if (retval == PROTOCOL_BINARY_RESPONSE_SUCCESS) {
uint32_t flags = 0;
uint64_t result_cas = 0;
if (Z_TYPE(zvalue) == IS_NULL) {
zval_ptr_dtor(¶ms[0]);
zval_ptr_dtor(¶ms[1]);
zval_ptr_dtor(¶ms[2]);
zval_ptr_dtor(¶ms[3]);
zval_ptr_dtor(¶ms[4]);
zval_ptr_dtor(&zcookie);
zval_ptr_dtor(&zkey);
zval_ptr_dtor(&zvalue);
zval_ptr_dtor(&zflags);
zval_ptr_dtor(&zresult_cas);
return PROTOCOL_BINARY_RESPONSE_KEY_ENOENT;
}
if (Z_TYPE(zvalue) != IS_STRING) {
convert_to_string (&zvalue);
}
if (Z_TYPE(zflags) == IS_LONG) {
flags = Z_LVAL(zflags);
}
MEMC_MAKE_RESULT_CAS(zresult_cas, result_cas);
retval = response_handler(cookie, key, key_len, Z_STRVAL(zvalue), Z_STRLEN(zvalue), flags, result_cas);
}
zval_ptr_dtor(¶ms[0]);
zval_ptr_dtor(¶ms[1]);
zval_ptr_dtor(¶ms[2]);
zval_ptr_dtor(¶ms[3]);
zval_ptr_dtor(¶ms[4]);
zval_ptr_dtor (&zcookie);
zval_ptr_dtor (&zkey);
zval_ptr_dtor (&zvalue);
zval_ptr_dtor (&zflags);
zval_ptr_dtor (&zresult_cas);
return retval;
}