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