Changed memcached_servers_parse() to take const
[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 #ifdef MEMCACHED_INTERNAL
22 #include <libmemcached/libmemcached_config.h>
23 #endif
24 #include <libmemcached/memcached_constants.h>
25 #include <libmemcached/memcached_types.h>
26 #include <libmemcached/memcached_watchpoint.h>
27 #include <libmemcached/memcached_get.h>
28 #include <libmemcached/memcached_server.h>
29 #include <libmemcached/memcached_string.h>
30 #include <libmemcached/memcached_result.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /* These are Private and should not be used by applications */
37 #define MEMCACHED_VERSION_STRING_LENGTH 12
38
39 /* string value */
40 struct memcached_continuum_item_st {
41 uint32_t index;
42 uint32_t value;
43 };
44
45 #define LIBMEMCACHED_VERSION_STRING "0.25"
46
47 struct memcached_stat_st {
48 uint32_t pid;
49 uint32_t uptime;
50 uint32_t threads;
51 uint32_t time;
52 uint32_t pointer_size;
53 uint32_t rusage_user_seconds;
54 uint32_t rusage_user_microseconds;
55 uint32_t rusage_system_seconds;
56 uint32_t rusage_system_microseconds;
57 uint32_t curr_items;
58 uint32_t total_items;
59 uint64_t limit_maxbytes;
60 uint32_t curr_connections;
61 uint32_t total_connections;
62 uint32_t connection_structures;
63 uint64_t bytes;
64 uint64_t cmd_get;
65 uint64_t cmd_set;
66 uint64_t get_hits;
67 uint64_t get_misses;
68 uint64_t evictions;
69 uint64_t bytes_read;
70 uint64_t bytes_written;
71 char version[MEMCACHED_VERSION_STRING_LENGTH];
72 };
73
74 struct memcached_st {
75 uint8_t purging;
76 bool is_allocated;
77 memcached_server_st *hosts;
78 uint32_t number_of_hosts;
79 uint32_t cursor_server;
80 int cached_errno;
81 uint32_t flags;
82 int send_size;
83 int recv_size;
84 int32_t poll_timeout;
85 int32_t connect_timeout;
86 int32_t retry_timeout;
87 memcached_result_st result;
88 memcached_hash hash;
89 memcached_server_distribution distribution;
90 void *user_data;
91 uint32_t continuum_count;
92 memcached_continuum_item_st *continuum;
93 memcached_clone_func on_clone;
94 memcached_cleanup_func on_cleanup;
95 memcached_free_function call_free;
96 memcached_malloc_function call_malloc;
97 memcached_realloc_function call_realloc;
98 memcached_trigger_key get_key_failure;
99 memcached_trigger_delete_key delete_trigger;
100 char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE];
101 size_t prefix_key_length;
102 memcached_hash hash_continuum;
103 uint32_t continuum_points_counter;
104 int32_t snd_timeout;
105 int32_t rcv_timeout;
106 uint32_t server_failure_limit;
107 uint32_t io_msg_watermark;
108 uint32_t io_bytes_watermark;
109 };
110
111
112 /* Public API */
113 const char * memcached_lib_version(void);
114
115 memcached_st *memcached_create(memcached_st *ptr);
116 void memcached_free(memcached_st *ptr);
117 memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr);
118
119 memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
120 time_t expiration);
121 memcached_return memcached_increment(memcached_st *ptr,
122 const char *key, size_t key_length,
123 uint32_t offset,
124 uint64_t *value);
125 memcached_return memcached_decrement(memcached_st *ptr,
126 const char *key, size_t key_length,
127 uint32_t offset,
128 uint64_t *value);
129 void memcached_stat_free(memcached_st *, memcached_stat_st *);
130 memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return *error);
131 memcached_return memcached_stat_servername(memcached_stat_st *stat, char *args,
132 char *hostname, unsigned int port);
133 memcached_return memcached_flush(memcached_st *ptr, time_t expiration);
134 memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity);
135 void memcached_quit(memcached_st *ptr);
136 char *memcached_strerror(memcached_st *ptr, memcached_return rc);
137 memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavior flag, uint64_t data);
138 uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior flag);
139
140 /* Server Public functions */
141
142 memcached_return memcached_server_add_udp(memcached_st *ptr,
143 const char *hostname,
144 unsigned int port);
145 memcached_return memcached_server_add_unix_socket(memcached_st *ptr,
146 const char *filename);
147 memcached_return memcached_server_add(memcached_st *ptr, const char *hostname,
148 unsigned int port);
149
150 memcached_return memcached_server_add_udp_with_weight(memcached_st *ptr,
151 const char *hostname,
152 unsigned int port,
153 uint32_t weight);
154 memcached_return memcached_server_add_unix_socket_with_weight(memcached_st *ptr,
155 const char *filename,
156 uint32_t weight);
157 memcached_return memcached_server_add_with_weight(memcached_st *ptr, const char *hostname,
158 unsigned int port,
159 uint32_t weight);
160 void memcached_server_list_free(memcached_server_st *ptr);
161 memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *list);
162
163 memcached_server_st *memcached_server_list_append(memcached_server_st *ptr,
164 const char *hostname,
165 unsigned int port,
166 memcached_return *error);
167 memcached_server_st *memcached_server_list_append_with_weight(memcached_server_st *ptr,
168 const char *hostname,
169 unsigned int port,
170 uint32_t weight,
171 memcached_return *error);
172 unsigned int memcached_server_list_count(memcached_server_st *ptr);
173 memcached_server_st *memcached_servers_parse(const char *server_strings);
174
175 char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *stat,
176 const char *key, memcached_return *error);
177 char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *stat,
178 memcached_return *error);
179
180 memcached_return memcached_delete_by_key(memcached_st *ptr,
181 const char *master_key, size_t master_key_length,
182 const char *key, size_t key_length,
183 time_t expiration);
184
185 memcached_return memcached_fetch_execute(memcached_st *ptr,
186 memcached_execute_function *callback,
187 void *context,
188 unsigned int number_of_callbacks);
189
190 memcached_return memcached_callback_set(memcached_st *ptr,
191 memcached_callback flag,
192 void *data);
193 void *memcached_callback_get(memcached_st *ptr,
194 memcached_callback flag,
195 memcached_return *error);
196
197
198 #ifdef __cplusplus
199 }
200 #endif
201
202 #include <libmemcached/memcached_storage.h>
203
204 #endif /* __MEMCACHED_H__ */