|
| 1 | +#include "test/lib/common.hpp" |
| 2 | +#include "libmemcached/common.h" |
| 3 | +#include "libmemcachedutil/common.h" |
| 4 | + |
| 5 | +static inline memcached_return_t ping_callback(const memcached_st *, const memcached_instance_st *instance, void *) { |
| 6 | + memcached_return_t rc; |
| 7 | + |
| 8 | + REQUIRE(libmemcached_util_ping(memcached_server_name(instance), memcached_server_port(instance), &rc)); |
| 9 | + REQUIRE(rc == MEMCACHED_SUCCESS); |
| 10 | + return MEMCACHED_SUCCESS; |
| 11 | +} |
| 12 | + |
| 13 | +static inline memcached_return_t ping2_callback(const memcached_st *, const memcached_instance_st *instance, void *) { |
| 14 | + memcached_return_t rc; |
| 15 | + |
| 16 | + REQUIRE(libmemcached_util_ping2(memcached_server_name(instance), memcached_server_port(instance), "memcached", "memcached", &rc)); |
| 17 | + REQUIRE(rc == MEMCACHED_SUCCESS); |
| 18 | + return MEMCACHED_SUCCESS; |
| 19 | +} |
| 20 | + |
| 21 | +static inline memcached_return_t callback_counter(const memcached_st *, memcached_result_st *, void *context) { |
| 22 | + auto *counter= reinterpret_cast<size_t *>(context); |
| 23 | + *counter = *counter + 1; |
| 24 | + |
| 25 | + return MEMCACHED_SUCCESS; |
| 26 | +} |
| 27 | + |
| 28 | +static inline memcached_return_t delete_trigger(memcached_st *, const char *, size_t) { |
| 29 | + return MEMCACHED_SUCCESS; |
| 30 | +} |
| 31 | + |
| 32 | +static inline memcached_return_t read_through_trigger(memcached_st *, char *, size_t, memcached_result_st *result) { |
| 33 | + return memcached_result_set_value(result, S("updated by read through trigger")); |
| 34 | +} |
| 35 | + |
| 36 | +static inline memcached_return_t clone_callback(memcached_st *, memcached_st *) { |
| 37 | + return MEMCACHED_SUCCESS; |
| 38 | +} |
| 39 | + |
| 40 | +static inline memcached_return_t cleanup_callback(memcached_st *) { |
| 41 | + return MEMCACHED_SUCCESS; |
| 42 | +} |
| 43 | + |
| 44 | +static inline memcached_return_t server_sort_callback(const memcached_st *, const memcached_instance_st *server, void *context) { |
| 45 | + if (context) { |
| 46 | + auto bigger = reinterpret_cast<size_t *>(context); |
| 47 | + REQUIRE(*bigger <= memcached_server_port(server)); |
| 48 | + *bigger = memcached_server_port(server); |
| 49 | + } |
| 50 | + return MEMCACHED_SUCCESS; |
| 51 | +} |
| 52 | + |
0 commit comments