2 * Copyright (C) 2006-2009 Brian Aker
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
8 * Summary: interface for memcached server
9 * Description: main include file for libmemcached
13 #ifndef __MEMCACHED_H__
14 #define __MEMCACHED_H__
19 #if !defined(__cplusplus)
23 #include <sys/types.h>
24 #include <netinet/in.h>
26 #include <libmemcached/visibility.h>
27 #include <libmemcached/configure.h>
28 #include <libmemcached/constants.h>
29 #include <libmemcached/types.h>
30 #include <libmemcached/string.h>
31 #include <libmemcached/stats.h>
32 #include <libhashkit/hashkit.h>
33 // Everything above this line must be in the order specified.
34 #include <libmemcached/allocators.h>
35 #include <libmemcached/analyze.h>
36 #include <libmemcached/auto.h>
37 #include <libmemcached/behavior.h>
38 #include <libmemcached/callback.h>
39 #include <libmemcached/delete.h>
40 #include <libmemcached/dump.h>
41 #include <libmemcached/fetch.h>
42 #include <libmemcached/flush.h>
43 #include <libmemcached/flush_buffers.h>
44 #include <libmemcached/get.h>
45 #include <libmemcached/hash.h>
46 #include <libmemcached/parse.h>
47 #include <libmemcached/quit.h>
48 #include <libmemcached/result.h>
49 #include <libmemcached/server.h>
50 #include <libmemcached/storage.h>
51 #include <libmemcached/strerror.h>
52 #include <libmemcached/verbosity.h>
53 #include <libmemcached/version.h>
60 void memcached_servers_reset(memcached_st
*ptr
);
63 memcached_st
*memcached_create(memcached_st
*ptr
);
66 void memcached_free(memcached_st
*ptr
);
69 memcached_st
*memcached_clone(memcached_st
*clone
, const memcached_st
*ptr
);
72 void *memcached_get_user_data(const memcached_st
*ptr
);
75 void *memcached_set_user_data(memcached_st
*ptr
, void *data
);
80 @note these are static and should not change without a call to behavior.
84 bool is_processing_input
:1;
87 // Everything below here is pretty static.
88 bool auto_eject_hosts
:1;
89 bool binary_protocol
:1;
90 bool buffer_requests
:1;
92 bool hash_with_prefix_key
:1;
93 bool ketama_weighted
:1;
96 bool randomize_replica_read
:1;
100 bool use_cache_lookups
:1;
101 bool use_sort_hosts
:1;
105 memcached_server_distribution_t distribution
;
107 uint32_t continuum_points_counter
; // Ketama
108 uint32_t number_of_hosts
;
109 memcached_server_st
*servers
;
110 memcached_server_st
*last_disconnected_server
;
113 uint32_t server_failure_limit
;
114 uint32_t io_msg_watermark
;
115 uint32_t io_bytes_watermark
;
116 uint32_t io_key_prefetch
;
118 int32_t poll_timeout
;
119 int32_t connect_timeout
;
120 int32_t retry_timeout
;
121 uint32_t continuum_count
; // Ketama
125 time_t next_distribution_rebuild
; // Ketama
126 size_t prefix_key_length
;
127 uint32_t number_of_replicas
;
128 hashkit_st distribution_hashkit
;
129 memcached_result_st result
;
130 memcached_continuum_item_st
*continuum
; // Ketama
132 struct _allocators_st
{
133 memcached_calloc_fn calloc
;
134 memcached_free_fn free
;
135 memcached_malloc_fn malloc
;
136 memcached_realloc_fn realloc
;
140 memcached_clone_fn on_clone
;
141 memcached_cleanup_fn on_cleanup
;
142 memcached_trigger_key_fn get_key_failure
;
143 memcached_trigger_delete_key_fn delete_trigger
;
144 memcached_callback_st
*callbacks
;
145 char prefix_key
[MEMCACHED_PREFIX_KEY_MAX_SIZE
];
156 continuum_points_counter(),
159 last_disconnected_server(),
162 server_failure_limit(),
164 io_bytes_watermark(),
174 next_distribution_rebuild(),
176 number_of_replicas(),
177 distribution_hashkit(),
189 memcached_create(this);
194 memcached_free(this);
197 memcached_st(const memcached_st
& source
) :
202 continuum_points_counter(),
205 last_disconnected_server(),
208 server_failure_limit(),
210 io_bytes_watermark(),
220 next_distribution_rebuild(),
222 number_of_replicas(),
223 distribution_hashkit(),
235 memcached_clone(this, &source
);
238 memcached_st
& operator=(const memcached_st
& source
)
240 memcached_clone(this, &source
);
249 static inline memcached_server_st
*memcached_server_instance_fetch(memcached_st
*ptr
, uint32_t server_key
)
251 return &ptr
->servers
[server_key
];
260 #endif /* __MEMCACHED_H__ */