Update pandora
[m6w6/libmemcached] / libmemcached / memcached.h
1 /*
2 * Summary: interface for memcached server
3 * Description: main include file for libmemcached
4 *
5 * Copy: See Copyright for the status of this software.
6 *
7 * Author: Brian Aker
8 */
9
10 #ifndef __MEMCACHED_H__
11 #define __MEMCACHED_H__
12
13 #include <stdlib.h>
14 #include <inttypes.h>
15 #if !defined(__cplusplus)
16 # include <stdbool.h>
17 #endif
18 #include <sys/types.h>
19 #include <netinet/in.h>
20
21 #include <libmemcached/visibility.h>
22 #include <libmemcached/memcached_configure.h>
23 #include <libmemcached/memcached_constants.h>
24 #include <libmemcached/memcached_types.h>
25 #include <libmemcached/memcached_get.h>
26 #include <libmemcached/memcached_server.h>
27 #include <libmemcached/memcached_string.h>
28 #include <libmemcached/memcached_result.h>
29 #include <libmemcached/memcached_storage.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define MEMCACHED_VERSION_STRING_LENGTH 24
36 #define LIBMEMCACHED_VERSION_STRING "0.32"
37
38 struct memcached_analysis_st {
39 uint32_t average_item_size;
40 uint32_t longest_uptime;
41 uint32_t least_free_server;
42 uint32_t most_consumed_server;
43 uint32_t oldest_server;
44 double pool_hit_ratio;
45 uint64_t most_used_bytes;
46 uint64_t least_remaining_bytes;
47 };
48
49 struct memcached_stat_st {
50 uint32_t connection_structures;
51 uint32_t curr_connections;
52 uint32_t curr_items;
53 uint32_t pid;
54 uint32_t pointer_size;
55 uint32_t rusage_system_microseconds;
56 uint32_t rusage_system_seconds;
57 uint32_t rusage_user_microseconds;
58 uint32_t rusage_user_seconds;
59 uint32_t threads;
60 uint32_t time;
61 uint32_t total_connections;
62 uint32_t total_items;
63 uint32_t uptime;
64 uint64_t bytes;
65 uint64_t bytes_read;
66 uint64_t bytes_written;
67 uint64_t cmd_get;
68 uint64_t cmd_set;
69 uint64_t evictions;
70 uint64_t get_hits;
71 uint64_t get_misses;
72 uint64_t limit_maxbytes;
73 char version[MEMCACHED_VERSION_STRING_LENGTH];
74 };
75
76 struct memcached_st {
77 uint8_t purging;
78 bool is_allocated;
79 uint8_t distribution;
80 uint8_t hash;
81 uint32_t continuum_points_counter;
82 memcached_server_st *hosts;
83 int32_t snd_timeout;
84 int32_t rcv_timeout;
85 uint32_t server_failure_limit;
86 uint32_t io_msg_watermark;
87 uint32_t io_bytes_watermark;
88 uint32_t io_key_prefetch;
89 uint32_t number_of_hosts;
90 uint32_t cursor_server;
91 int cached_errno;
92 uint32_t flags;
93 int32_t poll_timeout;
94 int32_t connect_timeout;
95 int32_t retry_timeout;
96 uint32_t continuum_count;
97 int send_size;
98 int recv_size;
99 void *user_data;
100 time_t next_distribution_rebuild;
101 size_t prefix_key_length;
102 memcached_hash hash_continuum;
103 memcached_result_st result;
104 memcached_continuum_item_st *continuum;
105 memcached_clone_func on_clone;
106 memcached_cleanup_func on_cleanup;
107 memcached_free_function call_free;
108 memcached_malloc_function call_malloc;
109 memcached_realloc_function call_realloc;
110 memcached_calloc_function call_calloc;
111 memcached_trigger_key get_key_failure;
112 memcached_trigger_delete_key delete_trigger;
113 char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE];
114 uint32_t number_of_replicas;
115 };
116
117 LIBMEMCACHED_API
118 memcached_return memcached_version(memcached_st *ptr);
119
120 /* Public API */
121
122 LIBMEMCACHED_API
123 const char * memcached_lib_version(void);
124
125 LIBMEMCACHED_API
126 memcached_st *memcached_create(memcached_st *ptr);
127 LIBMEMCACHED_API
128 void memcached_free(memcached_st *ptr);
129 LIBMEMCACHED_API
130 memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr);
131
132 LIBMEMCACHED_API
133 memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
134 time_t expiration);
135 LIBMEMCACHED_API
136 memcached_return memcached_increment(memcached_st *ptr,
137 const char *key, size_t key_length,
138 uint32_t offset,
139 uint64_t *value);
140 LIBMEMCACHED_API
141 memcached_return memcached_decrement(memcached_st *ptr,
142 const char *key, size_t key_length,
143 uint32_t offset,
144 uint64_t *value);
145 LIBMEMCACHED_API
146 memcached_return memcached_increment_with_initial(memcached_st *ptr,
147 const char *key,
148 size_t key_length,
149 uint64_t offset,
150 uint64_t initial,
151 time_t expiration,
152 uint64_t *value);
153 LIBMEMCACHED_API
154 memcached_return memcached_decrement_with_initial(memcached_st *ptr,
155 const char *key,
156 size_t key_length,
157 uint64_t offset,
158 uint64_t initial,
159 time_t expiration,
160 uint64_t *value);
161 LIBMEMCACHED_API
162 void memcached_stat_free(memcached_st *, memcached_stat_st *);
163 LIBMEMCACHED_API
164 memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return *error);
165 LIBMEMCACHED_API
166 memcached_return memcached_stat_servername(memcached_stat_st *memc_stat, char *args,
167 char *hostname, unsigned int port);
168 LIBMEMCACHED_API
169 memcached_return memcached_flush(memcached_st *ptr, time_t expiration);
170 LIBMEMCACHED_API
171 memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity);
172 LIBMEMCACHED_API
173 void memcached_quit(memcached_st *ptr);
174 LIBMEMCACHED_API
175 const char *memcached_strerror(memcached_st *ptr, memcached_return rc);
176 LIBMEMCACHED_API
177 memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavior flag, uint64_t data);
178 LIBMEMCACHED_API
179 uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior flag);
180
181 /* The two public hash bits */
182 LIBMEMCACHED_API
183 uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash hash_algorithm);
184 LIBMEMCACHED_API
185 uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_length);
186
187 LIBMEMCACHED_API
188 memcached_return memcached_flush_buffers(memcached_st *mem);
189
190 /* Server Public functions */
191
192 LIBMEMCACHED_API
193 memcached_return memcached_server_add_udp(memcached_st *ptr,
194 const char *hostname,
195 unsigned int port);
196 LIBMEMCACHED_API
197 memcached_return memcached_server_add_unix_socket(memcached_st *ptr,
198 const char *filename);
199 LIBMEMCACHED_API
200 memcached_return memcached_server_add(memcached_st *ptr, const char *hostname,
201 unsigned int port);
202
203 LIBMEMCACHED_API
204 memcached_return memcached_server_add_udp_with_weight(memcached_st *ptr,
205 const char *hostname,
206 unsigned int port,
207 uint32_t weight);
208 LIBMEMCACHED_API
209 memcached_return memcached_server_add_unix_socket_with_weight(memcached_st *ptr,
210 const char *filename,
211 uint32_t weight);
212 LIBMEMCACHED_API
213 memcached_return memcached_server_add_with_weight(memcached_st *ptr, const char *hostname,
214 unsigned int port,
215 uint32_t weight);
216 LIBMEMCACHED_API
217 void memcached_server_list_free(memcached_server_st *ptr);
218 LIBMEMCACHED_API
219 memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *list);
220
221 LIBMEMCACHED_API
222 memcached_server_st *memcached_server_list_append(memcached_server_st *ptr,
223 const char *hostname,
224 unsigned int port,
225 memcached_return *error);
226 LIBMEMCACHED_API
227 memcached_server_st *memcached_server_list_append_with_weight(memcached_server_st *ptr,
228 const char *hostname,
229 unsigned int port,
230 uint32_t weight,
231 memcached_return *error);
232 LIBMEMCACHED_API
233 unsigned int memcached_server_list_count(memcached_server_st *ptr);
234 LIBMEMCACHED_API
235 memcached_server_st *memcached_servers_parse(const char *server_strings);
236
237 LIBMEMCACHED_API
238 char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_stat,
239 const char *key, memcached_return *error);
240 LIBMEMCACHED_API
241 char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat,
242 memcached_return *error);
243
244 LIBMEMCACHED_API
245 memcached_return memcached_delete_by_key(memcached_st *ptr,
246 const char *master_key, size_t master_key_length,
247 const char *key, size_t key_length,
248 time_t expiration);
249
250 LIBMEMCACHED_API
251 memcached_return memcached_fetch_execute(memcached_st *ptr,
252 memcached_execute_function *callback,
253 void *context,
254 unsigned int number_of_callbacks);
255
256 LIBMEMCACHED_API
257 memcached_return memcached_callback_set(memcached_st *ptr,
258 memcached_callback flag,
259 void *data);
260 LIBMEMCACHED_API
261 void *memcached_callback_get(memcached_st *ptr,
262 memcached_callback flag,
263 memcached_return *error);
264
265 LIBMEMCACHED_API
266 memcached_return memcached_dump(memcached_st *ptr, memcached_dump_func *function, void *context, uint32_t number_of_callbacks);
267
268
269 LIBMEMCACHED_API
270 memcached_return memcached_set_memory_allocators(memcached_st *ptr,
271 memcached_malloc_function mem_malloc,
272 memcached_free_function mem_free,
273 memcached_realloc_function mem_realloc,
274 memcached_calloc_function mem_calloc);
275
276 LIBMEMCACHED_API
277 void memcached_get_memory_allocators(memcached_st *ptr,
278 memcached_malloc_function *mem_malloc,
279 memcached_free_function *mem_free,
280 memcached_realloc_function *mem_realloc,
281 memcached_calloc_function *mem_calloc);
282
283 LIBMEMCACHED_API
284 void *memcached_get_user_data(memcached_st *ptr);
285 LIBMEMCACHED_API
286 void *memcached_set_user_data(memcached_st *ptr, void *data);
287
288 LIBMEMCACHED_API
289 memcached_return run_distribution(memcached_st *ptr);
290 #ifdef __cplusplus
291 }
292 #endif
293
294
295 #endif /* __MEMCACHED_H__ */