2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
18 #include "test/lib/common.hpp"
19 #include "libmemcached/common.h"
20 #include "libmemcachedutil/common.h"
22 static inline memcached_return_t ping_callback(const memcached_st *,
23 const memcached_instance_st *instance, void *) {
24 memcached_return_t rc;
26 REQUIRE(libmemcached_util_ping(memcached_server_name(instance), memcached_server_port(instance),
28 REQUIRE(rc == MEMCACHED_SUCCESS);
29 return MEMCACHED_SUCCESS;
32 static inline memcached_return_t ping2_callback(const memcached_st *,
33 const memcached_instance_st *instance, void *) {
34 memcached_return_t rc;
36 REQUIRE(libmemcached_util_ping2(memcached_server_name(instance), memcached_server_port(instance),
37 "memcached", "memcached", &rc));
38 REQUIRE(rc == MEMCACHED_SUCCESS);
39 return MEMCACHED_SUCCESS;
42 static inline memcached_return_t callback_counter(const memcached_st *, memcached_result_st *,
44 auto *counter = reinterpret_cast<size_t *>(context);
45 *counter = *counter + 1;
47 return MEMCACHED_SUCCESS;
50 static inline memcached_return_t delete_trigger(memcached_st *, const char *, size_t) {
51 return MEMCACHED_SUCCESS;
54 static inline memcached_return_t get_failure(memcached_st *, char *, size_t,
55 memcached_result_st *result) {
56 return memcached_result_set_value(result, S("updated by read through trigger"));
59 static inline memcached_return_t clone_callback(memcached_st *, memcached_st *) {
60 return MEMCACHED_SUCCESS;
63 static inline memcached_return_t cleanup_callback(memcached_st *) {
64 return MEMCACHED_SUCCESS;
67 static inline memcached_return_t
68 server_sort_callback(const memcached_st *, const memcached_instance_st *server, void *context) {
70 auto bigger = reinterpret_cast<size_t *>(context);
71 REQUIRE(*bigger <= memcached_server_port(server));
72 *bigger = memcached_server_port(server);
74 return MEMCACHED_SUCCESS;