Merge from Trond
[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.33"
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 memcached_server_st *last_disconnected_server;
84 int32_t snd_timeout;
85 int32_t rcv_timeout;
86 uint32_t server_failure_limit;
87 uint32_t io_msg_watermark;
88 uint32_t io_bytes_watermark;
89 uint32_t io_key_prefetch;
90 uint32_t number_of_hosts;
91 uint32_t cursor_server;
92 int cached_errno;
93 uint32_t flags;
94 int32_t poll_timeout;
95 int32_t connect_timeout;
96 int32_t retry_timeout;
97 uint32_t continuum_count;
98 int send_size;
99 int recv_size;
100 void *user_data;
101 time_t next_distribution_rebuild;
102 size_t prefix_key_length;
103 memcached_hash hash_continuum;
104 memcached_result_st result;
105 memcached_continuum_item_st *continuum;
106 memcached_clone_func on_clone;
107 memcached_cleanup_func on_cleanup;
108 memcached_free_function call_free;
109 memcached_malloc_function call_malloc;
110 memcached_realloc_function call_realloc;
111 memcached_calloc_function call_calloc;
112 memcached_trigger_key get_key_failure;
113 memcached_trigger_delete_key delete_trigger;
114 char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE];
115 uint32_t number_of_replicas;
116 };
117
118 LIBMEMCACHED_API
119 memcached_return memcached_version(memcached_st *ptr);
120
121 /* Public API */
122
123 LIBMEMCACHED_API
124 const char * memcached_lib_version(void);
125
126 LIBMEMCACHED_API
127 memcached_st *memcached_create(memcached_st *ptr);
128 LIBMEMCACHED_API
129 void memcached_free(memcached_st *ptr);
130 LIBMEMCACHED_API
131 memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr);
132
133 LIBMEMCACHED_API
134 memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
135 time_t expiration);
136 LIBMEMCACHED_API
137 memcached_return memcached_increment(memcached_st *ptr,
138 const char *key, size_t key_length,
139 uint32_t offset,
140 uint64_t *value);
141 LIBMEMCACHED_API
142 memcached_return memcached_decrement(memcached_st *ptr,
143 const char *key, size_t key_length,
144 uint32_t offset,
145 uint64_t *value);
146 LIBMEMCACHED_API
147 memcached_return memcached_increment_with_initial(memcached_st *ptr,
148 const char *key,
149 size_t key_length,
150 uint64_t offset,
151 uint64_t initial,
152 time_t expiration,
153 uint64_t *value);
154 LIBMEMCACHED_API
155 memcached_return memcached_decrement_with_initial(memcached_st *ptr,
156 const char *key,
157 size_t key_length,
158 uint64_t offset,
159 uint64_t initial,
160 time_t expiration,
161 uint64_t *value);
162 LIBMEMCACHED_API
163 void memcached_stat_free(memcached_st *, memcached_stat_st *);
164 LIBMEMCACHED_API
165 memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return *error);
166 LIBMEMCACHED_API
167 memcached_return memcached_stat_servername(memcached_stat_st *memc_stat, char *args,
168 char *hostname, unsigned int port);
169 LIBMEMCACHED_API
170 memcached_return memcached_flush(memcached_st *ptr, time_t expiration);
171 LIBMEMCACHED_API
172 memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity);
173 LIBMEMCACHED_API
174 void memcached_quit(memcached_st *ptr);
175 LIBMEMCACHED_API
176 const char *memcached_strerror(memcached_st *ptr, memcached_return rc);
177 LIBMEMCACHED_API
178 memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavior flag, uint64_t data);
179 LIBMEMCACHED_API
180 uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior flag);
181
182 /* The two public hash bits */
183 LIBMEMCACHED_API
184 uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash hash_algorithm);
185 LIBMEMCACHED_API
186 uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_length);
187
188 LIBMEMCACHED_API
189 memcached_return memcached_flush_buffers(memcached_st *mem);
190
191 /* Server Public functions */
192
193 LIBMEMCACHED_API
194 memcached_return memcached_server_add_udp(memcached_st *ptr,
195 const char *hostname,
196 unsigned int port);
197 LIBMEMCACHED_API
198 memcached_return memcached_server_add_unix_socket(memcached_st *ptr,
199 const char *filename);
200 LIBMEMCACHED_API
201 memcached_return memcached_server_add(memcached_st *ptr, const char *hostname,
202 unsigned int port);
203
204 LIBMEMCACHED_API
205 memcached_return memcached_server_add_udp_with_weight(memcached_st *ptr,
206 const char *hostname,
207 unsigned int port,
208 uint32_t weight);
209 LIBMEMCACHED_API
210 memcached_return memcached_server_add_unix_socket_with_weight(memcached_st *ptr,
211 const char *filename,
212 uint32_t weight);
213 LIBMEMCACHED_API
214 memcached_return memcached_server_add_with_weight(memcached_st *ptr, const char *hostname,
215 unsigned int port,
216 uint32_t weight);
217 LIBMEMCACHED_API
218 void memcached_server_list_free(memcached_server_st *ptr);
219 LIBMEMCACHED_API
220 memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *list);
221
222 LIBMEMCACHED_API
223 memcached_server_st *memcached_server_list_append(memcached_server_st *ptr,
224 const char *hostname,
225 unsigned int port,
226 memcached_return *error);
227 LIBMEMCACHED_API
228 memcached_server_st *memcached_server_list_append_with_weight(memcached_server_st *ptr,
229 const char *hostname,
230 unsigned int port,
231 uint32_t weight,
232 memcached_return *error);
233 LIBMEMCACHED_API
234 unsigned int memcached_server_list_count(memcached_server_st *ptr);
235 LIBMEMCACHED_API
236 memcached_server_st *memcached_servers_parse(const char *server_strings);
237
238 LIBMEMCACHED_API
239 char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_stat,
240 const char *key, memcached_return *error);
241 LIBMEMCACHED_API
242 char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat,
243 memcached_return *error);
244
245 LIBMEMCACHED_API
246 memcached_return memcached_delete_by_key(memcached_st *ptr,
247 const char *master_key, size_t master_key_length,
248 const char *key, size_t key_length,
249 time_t expiration);
250
251 LIBMEMCACHED_API
252 memcached_return memcached_fetch_execute(memcached_st *ptr,
253 memcached_execute_function *callback,
254 void *context,
255 unsigned int number_of_callbacks);
256
257 LIBMEMCACHED_API
258 memcached_return memcached_callback_set(memcached_st *ptr,
259 memcached_callback flag,
260 void *data);
261 LIBMEMCACHED_API
262 void *memcached_callback_get(memcached_st *ptr,
263 memcached_callback flag,
264 memcached_return *error);
265
266 LIBMEMCACHED_API
267 memcached_return memcached_dump(memcached_st *ptr, memcached_dump_func *function, void *context, uint32_t number_of_callbacks);
268
269
270 LIBMEMCACHED_API
271 memcached_return memcached_set_memory_allocators(memcached_st *ptr,
272 memcached_malloc_function mem_malloc,
273 memcached_free_function mem_free,
274 memcached_realloc_function mem_realloc,
275 memcached_calloc_function mem_calloc);
276
277 LIBMEMCACHED_API
278 void memcached_get_memory_allocators(memcached_st *ptr,
279 memcached_malloc_function *mem_malloc,
280 memcached_free_function *mem_free,
281 memcached_realloc_function *mem_realloc,
282 memcached_calloc_function *mem_calloc);
283
284 LIBMEMCACHED_API
285 void *memcached_get_user_data(memcached_st *ptr);
286 LIBMEMCACHED_API
287 void *memcached_set_user_data(memcached_st *ptr, void *data);
288
289 LIBMEMCACHED_API
290 memcached_return run_distribution(memcached_st *ptr);
291 #ifdef __cplusplus
292 }
293 #endif
294
295
296 #endif /* __MEMCACHED_H__ */