Updating for 1.0.2 release
[awesomized/libmemcached] / libmemcached-1.0 / memcached.h
1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Libmemcached library
4 *
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
6 * Copyright (C) 2006-2009 Brian Aker All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38 #pragma once
39
40 #include <inttypes.h>
41 #include <stdlib.h>
42 #include <sys/types.h>
43
44
45 #if !defined(__cplusplus)
46 # include <stdbool.h>
47 #endif
48
49 #include <libmemcached-1.0/visibility.h>
50 #include <libmemcached-1.0/configure.h>
51 #include <libmemcached-1.0/platform.h>
52 #include <libmemcached-1.0/constants.h>
53 #include <libmemcached-1.0/return.h>
54 #include <libmemcached-1.0/types.h>
55 #include <libmemcached-1.0/basic_string.h>
56 #include <libmemcached-1.0/string.h>
57 #include <libmemcached-1.0/error.h>
58 #include <libmemcached-1.0/stats.h>
59 #include <libhashkit-1.0/hashkit.h>
60
61 // Everything above this line must be in the order specified.
62 #include <libmemcached-1.0/allocators.h>
63 #include <libmemcached-1.0/analyze.h>
64 #include <libmemcached-1.0/auto.h>
65 #include <libmemcached-1.0/behavior.h>
66 #include <libmemcached-1.0/callback.h>
67 #include <libmemcached-1.0/delete.h>
68 #include <libmemcached-1.0/dump.h>
69 #include <libmemcached-1.0/exist.h>
70 #include <libmemcached-1.0/fetch.h>
71 #include <libmemcached-1.0/flush.h>
72 #include <libmemcached-1.0/flush_buffers.h>
73 #include <libmemcached-1.0/get.h>
74 #include <libmemcached-1.0/hash.h>
75 #include <libmemcached-1.0/options.h>
76 #include <libmemcached-1.0/parse.h>
77 #include <libmemcached-1.0/quit.h>
78 #include <libmemcached-1.0/result.h>
79 #include <libmemcached-1.0/server.h>
80 #include <libmemcached-1.0/server_list.h>
81 #include <libmemcached-1.0/storage.h>
82 #include <libmemcached-1.0/strerror.h>
83 #include <libmemcached-1.0/touch.h>
84 #include <libmemcached-1.0/verbosity.h>
85 #include <libmemcached-1.0/version.h>
86 #include <libmemcached-1.0/sasl.h>
87
88 struct memcached_st {
89 /**
90 @note these are static and should not change without a call to behavior.
91 */
92 struct {
93 bool is_purging:1;
94 bool is_processing_input:1;
95 bool is_time_for_rebuild:1;
96 } state;
97
98 struct {
99 // Everything below here is pretty static.
100 bool auto_eject_hosts:1;
101 bool binary_protocol:1;
102 bool buffer_requests:1;
103 bool hash_with_namespace:1;
104 bool no_block:1; // Don't block
105 bool no_reply:1;
106 bool randomize_replica_read:1;
107 bool support_cas:1;
108 bool tcp_nodelay:1;
109 bool use_sort_hosts:1;
110 bool use_udp:1;
111 bool verify_key:1;
112 bool tcp_keepalive:1;
113 } flags;
114
115 memcached_server_distribution_t distribution;
116 hashkit_st hashkit;
117 struct {
118 unsigned int version;
119 } server_info;
120 uint32_t number_of_hosts;
121 memcached_server_st *servers;
122 memcached_server_st *last_disconnected_server;
123 int32_t snd_timeout;
124 int32_t rcv_timeout;
125 uint32_t server_failure_limit;
126 uint32_t io_msg_watermark;
127 uint32_t io_bytes_watermark;
128 uint32_t io_key_prefetch;
129 uint32_t tcp_keepidle;
130 int32_t poll_timeout;
131 int32_t connect_timeout; // How long we will wait on connect() before we will timeout
132 int32_t retry_timeout;
133 int send_size;
134 int recv_size;
135 void *user_data;
136 uint64_t query_id;
137 uint32_t number_of_replicas;
138 memcached_result_st result;
139
140 struct {
141 bool weighted;
142 uint32_t continuum_count; // Ketama
143 uint32_t continuum_points_counter; // Ketama
144 time_t next_distribution_rebuild; // Ketama
145 memcached_continuum_item_st *continuum; // Ketama
146 } ketama;
147
148 struct memcached_virtual_bucket_t *virtual_bucket;
149
150 struct memcached_allocator_t allocators;
151
152 memcached_clone_fn on_clone;
153 memcached_cleanup_fn on_cleanup;
154 memcached_trigger_key_fn get_key_failure;
155 memcached_trigger_delete_key_fn delete_trigger;
156 memcached_callback_st *callbacks;
157 struct memcached_sasl_st sasl;
158 struct memcached_error_t *error_messages;
159 struct memcached_array_st *_namespace;
160 struct {
161 uint32_t initial_pool_size;
162 uint32_t max_pool_size;
163 int32_t version; // This is used by pool and others to determine if the memcached_st is out of date.
164 struct memcached_array_st *filename;
165 } configure;
166 struct {
167 bool is_allocated:1;
168 } options;
169
170 };
171
172 #ifdef __cplusplus
173 extern "C" {
174 #endif
175
176 LIBMEMCACHED_API
177 void memcached_servers_reset(memcached_st *ptr);
178
179 LIBMEMCACHED_API
180 memcached_st *memcached_create(memcached_st *ptr);
181
182 LIBMEMCACHED_API
183 memcached_st *memcached(const char *string, size_t string_length);
184
185 LIBMEMCACHED_API
186 void memcached_free(memcached_st *ptr);
187
188 LIBMEMCACHED_API
189 memcached_return_t memcached_reset(memcached_st *ptr);
190
191 LIBMEMCACHED_API
192 void memcached_reset_last_disconnected_server(memcached_st *ptr);
193
194 LIBMEMCACHED_API
195 memcached_st *memcached_clone(memcached_st *clone, const memcached_st *ptr);
196
197 LIBMEMCACHED_API
198 void *memcached_get_user_data(const memcached_st *ptr);
199
200 LIBMEMCACHED_API
201 void *memcached_set_user_data(memcached_st *ptr, void *data);
202
203 LIBMEMCACHED_API
204 memcached_return_t memcached_push(memcached_st *destination, const memcached_st *source);
205
206 LIBMEMCACHED_API
207 memcached_server_instance_st memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key);
208
209 LIBMEMCACHED_API
210 uint32_t memcached_server_count(const memcached_st *);
211
212 LIBMEMCACHED_API
213 uint64_t memcached_query_id(const memcached_st *);
214
215 #ifdef __cplusplus
216 } // extern "C"
217 #endif