1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
6 * Copyright (C) 2006-2009 Brian Aker
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following disclaimer
18 * in the documentation and/or other materials provided with the
21 * * The names of its contributors may not be used to endorse or
22 * promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 Common include file for libmemached
63 #include <sys/types.h>
70 #include <libmemcached-1.0/memcached.h>
71 #include <libmemcached/watchpoint.h>
72 #include <libmemcached/is.h>
74 #include <libmemcached/server_instance.h>
79 #include "poll/poll.h"
87 typedef memcached_return_t (*memcached_server_execute_fn
)(memcached_st
*ptr
, memcached_server_write_instance_st server
, void *context
);
90 memcached_server_write_instance_st
memcached_server_instance_fetch(memcached_st
*ptr
, uint32_t server_key
);
93 memcached_return_t
memcached_server_execute(memcached_st
*ptr
,
94 memcached_server_execute_fn callback
,
101 /* These are private not to be installed headers */
102 #include <libmemcached/error.hpp>
103 #include <libmemcached/memory.h>
104 #include <libmemcached/io.h>
106 #include <libmemcached/string.hpp>
107 #include <libmemcached/io.hpp>
108 #include <libmemcached/do.hpp>
110 #include <libmemcached/internal.h>
111 #include <libmemcached/array.h>
112 #include <libmemcached/libmemcached_probes.h>
113 #include <libmemcached/memcached/protocol_binary.h>
114 #include <libmemcached/byteorder.h>
115 #include <libmemcached/initialize_query.h>
116 #include <libmemcached/response.h>
117 #include <libmemcached/namespace.h>
120 #include <libmemcached/backtrace.hpp>
121 #include <libmemcached/assert.hpp>
122 #include <libmemcached/server.hpp>
125 #include <libmemcached/continuum.hpp>
127 #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
129 #define likely(x) if((x))
130 #define unlikely(x) if((x))
134 #define likely(x) if(__builtin_expect((x) != 0, 1))
135 #define unlikely(x) if(__builtin_expect((x) != 0, 0))
138 #define MEMCACHED_BLOCK_SIZE 1024
139 #define MEMCACHED_DEFAULT_COMMAND_SIZE 350
140 #define SMALL_STRING_LEN 1024
141 #define HUGE_STRING_LEN 8196
148 memcached_return_t
memcached_connect(memcached_server_write_instance_st ptr
);
151 memcached_return_t
run_distribution(memcached_st
*ptr
);
153 #define memcached_server_response_increment(A) (A)->cursor_active++
154 #define memcached_server_response_decrement(A) (A)->cursor_active--
155 #define memcached_server_response_reset(A) (A)->cursor_active=0
159 memcached_return_t
memcached_key_test(const memcached_st
& memc
,
160 const char * const *keys
,
161 const size_t *key_length
,
162 size_t number_of_keys
);
166 memcached_return_t
memcached_purge(memcached_server_write_instance_st ptr
);
169 static inline memcached_return_t
memcached_validate_key_length(size_t key_length
, bool binary
)
173 return MEMCACHED_BAD_KEY_PROVIDED
;
178 if (key_length
> 0xffff)
180 return MEMCACHED_BAD_KEY_PROVIDED
;
185 if (key_length
>= MEMCACHED_MAX_KEY
)
187 return MEMCACHED_BAD_KEY_PROVIDED
;
191 return MEMCACHED_SUCCESS
;