1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: 2 * 3 * Libmemcached library 4 * 5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/ 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are 10 * met: 11 * 12 * * Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * * Redistributions in binary form must reproduce the above 16 * copyright notice, this list of conditions and the following disclaimer 17 * in the documentation and/or other materials provided with the 18 * distribution. 19 * 20 * * The names of its contributors may not be used to endorse or 21 * promote products derived from this software without specific prior 22 * written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 * 36 */ 37 38 module memcache.functiond; 39 40 public import memcache; 41 42 import core.stdc.time; 43 44 extern (C): 45 nothrow: 46 //alloc.h 47 /** 48 Memory allocation functions. 49 */ 50 //allocators.h 51 memcached_return_t memcached_set_memory_allocators(memcached_st* ptr, 52 memcached_malloc_fn mem_malloc, memcached_free_fn mem_free, 53 memcached_realloc_fn mem_realloc, memcached_calloc_fn mem_calloc, void* context); 54 55 void memcached_get_memory_allocators(const memcached_st* ptr, 56 memcached_malloc_fn* mem_malloc, memcached_free_fn* mem_free, 57 memcached_realloc_fn* mem_realloc, memcached_calloc_fn* mem_calloc); 58 59 void* memcached_get_memory_allocators_context(const memcached_st* ptr); 60 61 //analyze.h 62 memcached_analysis_st* memcached_analyze(memcached_st* memc, 63 memcached_stat_st* memc_stat, memcached_return_t* error); 64 65 void memcached_analyze_free(memcached_analysis_st*); 66 67 //auto.h 68 memcached_return_t memcached_increment(memcached_st* ptr, const char* key, 69 size_t key_length, uint offset, ulong* value); 70 memcached_return_t memcached_decrement(memcached_st* ptr, const char* key, 71 size_t key_length, uint offset, ulong* value); 72 73 memcached_return_t memcached_increment_by_key(memcached_st* ptr, 74 const char* group_key, size_t group_key_length, const char* key, 75 size_t key_length, ulong offset, ulong* value); 76 77 memcached_return_t memcached_decrement_by_key(memcached_st* ptr, 78 const char* group_key, size_t group_key_length, const char* key, 79 size_t key_length, ulong offset, ulong* value); 80 81 memcached_return_t memcached_increment_with_initial(memcached_st* ptr, 82 const char* key, size_t key_length, ulong offset, ulong initial, 83 time_t expiration, ulong* value); 84 85 memcached_return_t memcached_decrement_with_initial(memcached_st* ptr, 86 const char* key, size_t key_length, ulong offset, ulong initial, 87 time_t expiration, ulong* value); 88 89 memcached_return_t memcached_increment_with_initial_by_key(memcached_st* ptr, 90 const char* group_key, size_t group_key_length, const char* key, 91 size_t key_length, ulong offset, ulong initial, time_t expiration, ulong* value); 92 93 memcached_return_t memcached_decrement_with_initial_by_key(memcached_st* ptr, 94 const char* group_key, size_t group_key_length, const char* key, 95 size_t key_length, ulong offset, ulong initial, time_t expiration, ulong* value); 96 97 //behavior.h 98 memcached_return_t memcached_behavior_set(memcached_st* ptr, 99 const memcached_behavior_t flag, ulong data); 100 101 ulong memcached_behavior_get(memcached_st* ptr, const memcached_behavior_t flag); 102 103 memcached_return_t memcached_behavior_set_distribution(memcached_st* ptr, 104 memcached_server_distribution_t type); 105 106 memcached_server_distribution_t memcached_behavior_get_distribution(memcached_st* ptr); 107 108 memcached_return_t memcached_behavior_set_key_hash(memcached_st* ptr, memcached_hash_t type); 109 110 memcached_hash_t memcached_behavior_get_key_hash(memcached_st* ptr); 111 112 memcached_return_t memcached_behavior_set_distribution_hash(memcached_st* ptr, memcached_hash_t type); 113 114 memcached_hash_t memcached_behavior_get_distribution_hash(memcached_st* ptr); 115 116 char* libmemcached_string_behavior(const memcached_behavior_t flag); 117 118 char* libmemcached_string_distribution(const memcached_server_distribution_t flag); 119 120 memcached_return_t memcached_bucket_set(memcached_st* self, 121 const uint* host_map, const uint* forward_map, const uint buckets, const uint replicas); 122 123 //callback.h 124 memcached_return_t memcached_callback_set(memcached_st* ptr, 125 const memcached_callback_t flag, const void* data); 126 127 void* memcached_callback_get(memcached_st* ptr, const memcached_callback_t flag, 128 memcached_return_t* error); 129 130 //delete.h 131 memcached_return_t memcached_delete(memcached_st* ptr, const char* key, 132 size_t key_length, time_t expiration); 133 134 memcached_return_t memcached_delete_by_key(memcached_st* ptr, 135 const char* group_key, size_t group_key_length, const char* key, 136 size_t key_length, time_t expiration); 137 //dump.h 138 memcached_return_t memcached_dump(memcached_st* ptr, 139 memcached_dump_fn* cfunction, void* context, uint number_of_callbacks); 140 141 //error.h 142 143 char* memcached_error(const memcached_st*); 144 145 char* memcached_last_error_message(const memcached_st*); 146 147 void memcached_error_print(const memcached_st*); 148 149 memcached_return_t memcached_last_error(const memcached_st*); 150 151 int memcached_last_error_errno(const memcached_st*); 152 153 char* memcached_server_error(const memcached_instance_st* ptr); 154 155 memcached_return_t memcached_server_error_return(const memcached_instance_st* ptr); 156 157 //encoding_key.h 158 memcached_return_t memcached_set_encoding_key(memcached_st*, const char* str, size_t length); 159 160 //exist.h 161 memcached_return_t memcached_exist(memcached_st* memc, const char* key, size_t key_length); 162 163 memcached_return_t memcached_exist_by_key(memcached_st* memc, 164 const char* group_key, size_t group_key_length, const char* key, size_t key_length); 165 166 //fetch.h 167 memcached_return_t memcached_fetch_execute(memcached_st* ptr, 168 memcached_execute_fn* callback, void* context, uint number_of_callbacks); 169 170 //fluash.h 171 memcached_return_t memcached_flush(memcached_st* ptr, time_t expiration); 172 173 //flush_buffers.h 174 memcached_return_t memcached_flush_buffers(memcached_st* mem); 175 176 //get.h 177 char* memcached_get(memcached_st* ptr, const char* key, size_t key_length, 178 size_t* value_length, uint* flags, memcached_return_t* error); 179 180 memcached_return_t memcached_mget(memcached_st* ptr, const char** keys, 181 const size_t* key_length, size_t number_of_keys); 182 183 char* memcached_get_by_key(memcached_st* ptr, const char* group_key, 184 size_t group_key_length, const char* key, size_t key_length, 185 size_t* value_length, uint* flags, memcached_return_t* error); 186 187 memcached_return_t memcached_mget_by_key(memcached_st* ptr, 188 const char* group_key, size_t group_key_length, const char** keys, 189 const size_t* key_length, const size_t number_of_keys); 190 191 char* memcached_fetch(memcached_st* ptr, char* key, size_t* key_length, 192 size_t* value_length, uint* flags, memcached_return_t* error); 193 194 memcached_result_st* memcached_fetch_result(memcached_st* ptr, 195 memcached_result_st* result, memcached_return_t* error); 196 197 memcached_return_t memcached_mget_execute(memcached_st* ptr, const char** keys, 198 const size_t* key_length, const size_t number_of_keys, 199 memcached_execute_fn* callback, void* context, const uint number_of_callbacks); 200 201 memcached_return_t memcached_mget_execute_by_key(memcached_st* ptr, 202 const char* group_key, size_t group_key_length, const char** keys, 203 const size_t* key_length, size_t number_of_keys, 204 memcached_execute_fn* callback, void* context, const uint number_of_callbacks); 205 206 //hash.d 207 uint memcached_generate_hash_value(const char* key, size_t key_length, 208 memcached_hash_t hash_algorithm); 209 210 hashkit_st* memcached_get_hashkit(const memcached_st* ptr); 211 212 memcached_return_t memcached_set_hashkit(memcached_st* ptr, hashkit_st* hashk); 213 214 uint memcached_generate_hash(const memcached_st* ptr, const char* key, size_t key_length); 215 216 void memcached_autoeject(memcached_st* ptr); 217 218 char* libmemcached_string_hash(memcached_hash_t type); 219 220 //options.h 221 memcached_return_t libmemcached_check_configuration(const char* option_string, 222 size_t length, char* error_buffer, size_t error_buffer_size); 223 224 //parse.h 225 memcached_server_list_st memcached_servers_parse(const char* server_strings); 226 227 //quit.h 228 void memcached_quit(memcached_st* ptr); 229 230 //result.d 231 void memcached_result_free(memcached_result_st* result); 232 233 void memcached_result_reset(memcached_result_st* ptr); 234 235 memcached_result_st* memcached_result_create(const memcached_st* ptr, memcached_result_st* result); 236 237 char* memcached_result_key_value(const memcached_result_st* self); 238 239 size_t memcached_result_key_length(const memcached_result_st* self); 240 241 char* memcached_result_value(const memcached_result_st* self); 242 243 char* memcached_result_take_value(memcached_result_st* self); 244 245 size_t memcached_result_length(const memcached_result_st* self); 246 247 uint memcached_result_flags(const memcached_result_st* self); 248 249 ulong memcached_result_cas(const memcached_result_st* self); 250 251 memcached_return_t memcached_result_set_value(memcached_result_st* ptr, 252 const char* value, size_t length); 253 254 void memcached_result_set_flags(memcached_result_st* self, uint flags); 255 256 void memcached_result_set_expiration(memcached_result_st* self, time_t expiration); 257 258 //touch.h 259 memcached_return_t memcached_touch(memcached_st* ptr, const char* key, 260 size_t key_length, time_t expiration); 261 262 memcached_return_t memcached_touch_by_key(memcached_st* ptr, 263 const char* group_key, size_t group_key_length, const char* key, 264 size_t key_length, time_t expiration); 265 266 version (sasl) 267 { 268 void memcached_set_sasl_callbacks(memcached_st* ptr, const sasl_callback_t* callbacks); 269 270 memcached_return_t memcached_set_sasl_auth_data(memcached_st* ptr, 271 const char* username, const char* password); 272 273 memcached_return_t memcached_destroy_sasl_auth_data(memcached_st* ptr); 274 275 sasl_callback_t* memcached_get_sasl_callbacks(memcached_st* ptr); 276 277 }