@@ -121,14 +121,14 @@ protocol_binary_response_status s_add_handler(const void *cookie, const void *ke
121
121
}
122
122
123
123
static
124
- protocol_binary_response_status s_append_handler ( const void * cookie , const void * key , uint16_t key_len ,
125
- const void * data , uint32_t data_len , uint64_t cas , uint64_t * result_cas )
124
+ protocol_binary_response_status s_append_prepend_handler ( php_memc_event_t event , const void * cookie , const void * key , uint16_t key_len ,
125
+ const void * data , uint32_t data_len , uint64_t cas , uint64_t * result_cas )
126
126
{
127
127
protocol_binary_response_status retval = PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND ;
128
128
zval * zkey , * zvalue , * zcas , * zresult_cas ;
129
129
zval * * params [4 ];
130
130
131
- if (!MEMC_HAS_CB (MEMC_SERVER_ON_APPEND )) {
131
+ if (!MEMC_HAS_CB (event )) {
132
132
return retval ;
133
133
}
134
134
@@ -149,7 +149,7 @@ protocol_binary_response_status s_append_handler(const void *cookie, const void
149
149
params [2 ] = & zcas ;
150
150
params [3 ] = & zresult_cas ;
151
151
152
- retval = s_invoke_php_callback (& MEMC_GET_CB (MEMC_SERVER_ON_APPEND ), params , 4 );
152
+ retval = s_invoke_php_callback (& MEMC_GET_CB (event ), params , 4 );
153
153
154
154
if (Z_TYPE_P (zresult_cas ) != IS_NULL ) {
155
155
convert_to_double (zresult_cas );
@@ -164,6 +164,22 @@ protocol_binary_response_status s_append_handler(const void *cookie, const void
164
164
return retval ;
165
165
}
166
166
167
+ static
168
+ protocol_binary_response_status s_append_handler (const void * cookie , const void * key , uint16_t key_len ,
169
+ const void * data , uint32_t data_len , uint64_t cas , uint64_t * result_cas )
170
+ {
171
+ return
172
+ s_append_prepend_handler (MEMC_SERVER_ON_APPEND , cookie , key , key_len , data , data_len , cas , result_cas );
173
+ }
174
+
175
+ static
176
+ protocol_binary_response_status s_prepend_handler (const void * cookie , const void * key , uint16_t key_len ,
177
+ const void * data , uint32_t data_len , uint64_t cas , uint64_t * result_cas )
178
+ {
179
+ return
180
+ s_append_prepend_handler (MEMC_SERVER_ON_PREPEND , cookie , key , key_len , data , data_len , cas , result_cas );
181
+ }
182
+
167
183
static
168
184
protocol_binary_response_status s_incr_decr_handler (php_memc_event_t event , const void * cookie , const void * key , uint16_t key_len , uint64_t delta ,
169
185
uint64_t initial , uint32_t expiration , uint64_t * result , uint64_t * result_cas )
@@ -288,6 +304,85 @@ protocol_binary_response_status s_flush_handler(const void *cookie, uint32_t whe
288
304
return retval ;
289
305
}
290
306
307
+ static
308
+ protocol_binary_response_status s_get_handler (const void * cookie , const void * key , uint16_t key_len ,
309
+ memcached_binary_protocol_get_response_handler response_handler )
310
+ {
311
+ protocol_binary_response_status retval = PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND ;
312
+ zval * zkey , * zvalue , * zflags , * zresult_cas ;
313
+ zval * * params [4 ];
314
+
315
+ if (!MEMC_HAS_CB (MEMC_SERVER_ON_GET )) {
316
+ return retval ;
317
+ }
318
+
319
+ MAKE_STD_ZVAL (zkey );
320
+ ZVAL_STRINGL (zkey , key , key_len , 1 );
321
+
322
+ MAKE_STD_ZVAL (zvalue );
323
+ ZVAL_NULL (zvalue );
324
+
325
+ MAKE_STD_ZVAL (zflags );
326
+ ZVAL_NULL (zflags );
327
+
328
+ MAKE_STD_ZVAL (zresult_cas );
329
+ ZVAL_NULL (zresult_cas );
330
+
331
+ params [0 ] = & zkey ;
332
+ params [1 ] = & zvalue ;
333
+ params [2 ] = & zflags ;
334
+ params [3 ] = & zresult_cas ;
335
+
336
+ retval = s_invoke_php_callback (& MEMC_GET_CB (MEMC_SERVER_ON_GET ), params , 4 );
337
+
338
+ /* Succeeded in getting the key */
339
+ if (retval == PROTOCOL_BINARY_RESPONSE_SUCCESS ) {
340
+ uint32_t flags = 0 ;
341
+ uint64_t result_cas = 0 ;
342
+
343
+ if (Z_TYPE_P (zvalue ) == IS_NULL ) {
344
+ zval_ptr_dtor (& zkey );
345
+ zval_ptr_dtor (& zvalue );
346
+ zval_ptr_dtor (& zflags );
347
+ zval_ptr_dtor (& zresult_cas );
348
+ return PROTOCOL_BINARY_RESPONSE_KEY_ENOENT ;
349
+ }
350
+
351
+ if (Z_TYPE_P (zvalue ) != IS_STRING ) {
352
+ convert_to_string (zvalue );
353
+ }
354
+
355
+ if (Z_TYPE_P (zflags ) == IS_LONG ) {
356
+ flags = Z_LVAL_P (zflags );
357
+ }
358
+
359
+ if (Z_TYPE_P (zresult_cas ) != IS_NULL ) {
360
+ if (Z_TYPE_P (zresult_cas ) != IS_DOUBLE ) {
361
+ convert_to_double (zresult_cas );
362
+ }
363
+ result_cas = (uint64_t ) Z_DVAL_P (zresult_cas );
364
+ }
365
+ retval = response_handler (cookie , key , key_len , Z_STRVAL_P (zvalue ), Z_STRLEN_P (zvalue ), flags , result_cas );
366
+ }
367
+
368
+ zval_ptr_dtor (& zkey );
369
+ zval_ptr_dtor (& zvalue );
370
+ zval_ptr_dtor (& zflags );
371
+ zval_ptr_dtor (& zresult_cas );
372
+ return retval ;
373
+ }
374
+
375
+ static
376
+ protocol_binary_response_status s_noop_handler (const void * cookie )
377
+ {
378
+ protocol_binary_response_status retval = PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND ;
379
+
380
+ if (!MEMC_HAS_CB (MEMC_SERVER_ON_NOOP )) {
381
+ return retval ;
382
+ }
383
+ return s_invoke_php_callback (& MEMC_GET_CB (MEMC_SERVER_ON_NOOP ), NULL , 0 );
384
+ }
385
+
291
386
// libevent callbacks
292
387
293
388
static
@@ -377,13 +472,11 @@ php_memc_proto_handler_t *php_memc_proto_handler_new ()
377
472
handler -> callbacks .interface .v1 .decrement = s_decrement_handler ;
378
473
handler -> callbacks .interface .v1 .delete_object = s_delete_handler ;
379
474
handler -> callbacks .interface .v1 .flush_object = s_flush_handler ;
380
- /*
381
475
handler -> callbacks .interface .v1 .get = s_get_handler ;
382
- */
383
476
handler -> callbacks .interface .v1 .increment = s_increment_handler ;
384
- /*
385
477
handler -> callbacks .interface .v1 .noop = s_noop_handler ;
386
478
handler -> callbacks .interface .v1 .prepend = s_prepend_handler ;
479
+ /*
387
480
handler->callbacks.interface.v1.quit = s_quit_handler;
388
481
handler->callbacks.interface.v1.replace = s_replace_handler;
389
482
handler->callbacks.interface.v1.set = s_set_handler;
0 commit comments