Rearranged some things and added the visibility.m4 macros. Started to lay the
[awesomized/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/memcached_configure.h>
22 #include <libmemcached/memcached_constants.h>
23 #include <libmemcached/memcached_types.h>
24 #include <libmemcached/memcached_get.h>
25 #include <libmemcached/memcached_server.h>
26 #include <libmemcached/memcached_string.h>
27 #include <libmemcached/memcached_result.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #define MEMCACHED_VERSION_STRING_LENGTH 24
34 #define LIBMEMCACHED_VERSION_STRING "0.30"
35
36 struct memcached_analysis_st {
37 uint32_t average_item_size;
38 uint32_t longest_uptime;
39 uint32_t least_free_server;
40 uint32_t most_consumed_server;
41 uint32_t oldest_server;
42 double pool_hit_ratio;
43 uint64_t most_used_bytes;
44 uint64_t least_remaining_bytes;
45 };
46
47 struct memcached_stat_st {
48 uint32_t connection_structures;
49 uint32_t curr_connections;
50 uint32_t curr_items;
51 uint32_t pid;
52 uint32_t pointer_size;
53 uint32_t rusage_system_microseconds;
54 uint32_t rusage_system_seconds;
55 uint32_t rusage_user_microseconds;
56 uint32_t rusage_user_seconds;
57 uint32_t threads;
58 uint32_t time;
59 uint32_t total_connections;
60 uint32_t total_items;
61 uint32_t uptime;
62 uint64_t bytes;
63 uint64_t bytes_read;
64 uint64_t bytes_written;
65 uint64_t cmd_get;
66 uint64_t cmd_set;
67 uint64_t evictions;
68 uint64_t get_hits;
69 uint64_t get_misses;
70 uint64_t limit_maxbytes;
71 char version[MEMCACHED_VERSION_STRING_LENGTH];
72 };
73
74 struct memcached_st {
75 uint8_t purging;
76 bool is_allocated;
77 uint8_t distribution;
78 uint8_t hash;
79 uint32_t continuum_points_counter;
80 memcached_server_st *hosts;
81 int32_t snd_timeout;
82 int32_t rcv_timeout;
83 uint32_t server_failure_limit;
84 uint32_t io_msg_watermark;
85 uint32_t io_bytes_watermark;
86 uint32_t io_key_prefetch;
87 uint32_t number_of_hosts;
88 uint32_t cursor_server;
89 int cached_errno;
90 uint32_t flags;
91 int32_t poll_timeout;
92 int32_t connect_timeout;
93 int32_t retry_timeout;
94 uint32_t continuum_count;
95 int send_size;
96 int recv_size;
97 void *user_data;
98 time_t next_distribution_rebuild;
99 size_t prefix_key_length;
100 memcached_hash hash_continuum;
101 memcached_result_st result;
102 memcached_continuum_item_st *continuum;
103 memcached_clone_func on_clone;
104 memcached_cleanup_func on_cleanup;
105 memcached_free_function call_free;
106 memcached_malloc_function call_malloc;
107 memcached_realloc_function call_realloc;
108 memcached_calloc_function call_calloc;
109 memcached_trigger_key get_key_failure;
110 memcached_trigger_delete_key delete_trigger;
111 char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE];
112 uint32_t number_of_replicas;
113 };
114
115
116 /* Public API */
117 const char * memcached_lib_version(void);
118
119 memcached_st *memcached_create(memcached_st *ptr);
120 void memcached_free(memcached_st *ptr);
121 memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr);
122
123 memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
124 time_t expiration);
125 memcached_return memcached_increment(memcached_st *ptr,
126 const char *key, size_t key_length,
127 uint32_t offset,
128 uint64_t *value);
129 memcached_return memcached_decrement(memcached_st *ptr,
130 const char *key, size_t key_length,
131 uint32_t offset,
132 uint64_t *value);
133 memcached_return memcached_increment_with_initial(memcached_st *ptr,
134 const char *key,
135 size_t key_length,
136 uint64_t offset,
137 uint64_t initial,
138 time_t expiration,
139 uint64_t *value);
140 memcached_return memcached_decrement_with_initial(memcached_st *ptr,
141 const char *key,
142 size_t key_length,
143 uint64_t offset,
144 uint64_t initial,
145 time_t expiration,
146 uint64_t *value);
147 void memcached_stat_free(memcached_st *, memcached_stat_st *);
148 memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return *error);
149 memcached_return memcached_stat_servername(memcached_stat_st *stat, char *args,
150 char *hostname, unsigned int port);
151 memcached_return memcached_flush(memcached_st *ptr, time_t expiration);
152 memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity);
153 void memcached_quit(memcached_st *ptr);
154 char *memcached_strerror(memcached_st *ptr, memcached_return rc);
155 memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavior flag, uint64_t data);
156 uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior flag);
157
158 /* The two public hash bits */
159 uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash hash_algorithm);
160 uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_length);
161
162 memcached_return memcached_flush_buffers(memcached_st *mem);
163
164 /* Server Public functions */
165
166 memcached_return memcached_server_add_udp(memcached_st *ptr,
167 const char *hostname,
168 unsigned int port);
169 memcached_return memcached_server_add_unix_socket(memcached_st *ptr,
170 const char *filename);
171 memcached_return memcached_server_add(memcached_st *ptr, const char *hostname,
172 unsigned int port);
173
174 memcached_return memcached_server_add_udp_with_weight(memcached_st *ptr,
175 const char *hostname,
176 unsigned int port,
177 uint32_t weight);
178 memcached_return memcached_server_add_unix_socket_with_weight(memcached_st *ptr,
179 const char *filename,
180 uint32_t weight);
181 memcached_return memcached_server_add_with_weight(memcached_st *ptr, const char *hostname,
182 unsigned int port,
183 uint32_t weight);
184 void memcached_server_list_free(memcached_server_st *ptr);
185 memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *list);
186
187 memcached_server_st *memcached_server_list_append(memcached_server_st *ptr,
188 const char *hostname,
189 unsigned int port,
190 memcached_return *error);
191 memcached_server_st *memcached_server_list_append_with_weight(memcached_server_st *ptr,
192 const char *hostname,
193 unsigned int port,
194 uint32_t weight,
195 memcached_return *error);
196 unsigned int memcached_server_list_count(memcached_server_st *ptr);
197 memcached_server_st *memcached_servers_parse(const char *server_strings);
198
199 char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *stat,
200 const char *key, memcached_return *error);
201 char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *stat,
202 memcached_return *error);
203
204 memcached_return memcached_delete_by_key(memcached_st *ptr,
205 const char *master_key, size_t master_key_length,
206 const char *key, size_t key_length,
207 time_t expiration);
208
209 memcached_return memcached_fetch_execute(memcached_st *ptr,
210 memcached_execute_function *callback,
211 void *context,
212 unsigned int number_of_callbacks);
213
214 memcached_return memcached_callback_set(memcached_st *ptr,
215 memcached_callback flag,
216 void *data);
217 void *memcached_callback_get(memcached_st *ptr,
218 memcached_callback flag,
219 memcached_return *error);
220
221 memcached_return memcached_dump(memcached_st *ptr, memcached_dump_func *function, void *context, uint32_t number_of_callbacks);
222
223
224 memcached_return memcached_set_memory_allocators(memcached_st *ptr,
225 memcached_malloc_function mem_malloc,
226 memcached_free_function mem_free,
227 memcached_realloc_function mem_realloc,
228 memcached_calloc_function mem_calloc);
229
230 void memcached_get_memory_allocators(memcached_st *ptr,
231 memcached_malloc_function *mem_malloc,
232 memcached_free_function *mem_free,
233 memcached_realloc_function *mem_realloc,
234 memcached_calloc_function *mem_calloc);
235
236 void *memcached_get_user_data(memcached_st *ptr);
237 void *memcached_set_user_data(memcached_st *ptr, void *data);
238
239 #ifdef __cplusplus
240 }
241 #endif
242
243 #include <libmemcached/memcached_storage.h>
244
245 #endif /* __MEMCACHED_H__ */