memcached.h | memcached.h | |||
---|---|---|---|---|
skipping to change at line 22 | skipping to change at line 22 | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <inttypes.h> | #include <inttypes.h> | |||
#include <sys/types.h> | #include <sys/types.h> | |||
#include <netinet/in.h> | #include <netinet/in.h> | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
typedef struct memcached_st memcached_st; | /* These are Private and should not be used by applications */ | |||
typedef struct memcached_stat_st memcached_stat_st; | #define MEMCACHED_VERSION_STRING_LENGTH 12 | |||
typedef struct memcached_result_st memcached_result_st; | ||||
typedef struct memcached_string_st memcached_string_st; | ||||
typedef struct memcached_server_st memcached_server_st; | ||||
#define MEMCACHED_VERSION_STRING 12 | /* Public defines */ | |||
#define MEMCACHED_DEFAULT_PORT 11211 | #define MEMCACHED_DEFAULT_PORT 11211 | |||
#define MEMCACHED_DEFAULT_COMMAND_SIZE 350 | ||||
#define SMALL_STRING_LEN 1024 | ||||
#define HUGE_STRING_LEN 8196 | ||||
#define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */ | #define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */ | |||
#define MEMCACHED_MAX_BUFFER HUGE_STRING_LEN | #define MEMCACHED_MAX_BUFFER 8196 | |||
#define MEMCACHED_MAX_HOST_LENGTH 64 | #define MEMCACHED_MAX_HOST_LENGTH 64 | |||
#define MEMCACHED_WHEEL_SIZE 1024 | #define MEMCACHED_WHEEL_SIZE 1024 | |||
#define MEMCACHED_STRIDE 4 | #define MEMCACHED_STRIDE 4 | |||
#define MEMCACHED_DEFAULT_TIMEOUT INT32_MAX | #define MEMCACHED_DEFAULT_TIMEOUT INT32_MAX | |||
/* string value */ | ||||
#define LIBMEMCACHED_VERSION_STRING "0.14" | ||||
typedef enum { | typedef enum { | |||
MEMCACHED_SUCCESS, | MEMCACHED_SUCCESS, | |||
MEMCACHED_FAILURE, | MEMCACHED_FAILURE, | |||
MEMCACHED_HOST_LOOKUP_FAILURE, | MEMCACHED_HOST_LOOKUP_FAILURE, | |||
MEMCACHED_CONNECTION_FAILURE, | MEMCACHED_CONNECTION_FAILURE, | |||
MEMCACHED_CONNECTION_BIND_FAILURE, | MEMCACHED_CONNECTION_BIND_FAILURE, | |||
MEMCACHED_WRITE_FAILURE, | MEMCACHED_WRITE_FAILURE, | |||
MEMCACHED_READ_FAILURE, | MEMCACHED_READ_FAILURE, | |||
MEMCACHED_UNKNOWN_READ_FAILURE, | MEMCACHED_UNKNOWN_READ_FAILURE, | |||
MEMCACHED_PROTOCOL_ERROR, | MEMCACHED_PROTOCOL_ERROR, | |||
skipping to change at line 76 | skipping to change at line 73 | |||
MEMCACHED_ERRNO, | MEMCACHED_ERRNO, | |||
MEMCACHED_FAIL_UNIX_SOCKET, | MEMCACHED_FAIL_UNIX_SOCKET, | |||
MEMCACHED_NOT_SUPPORTED, | MEMCACHED_NOT_SUPPORTED, | |||
MEMCACHED_NO_KEY_PROVIDED, | MEMCACHED_NO_KEY_PROVIDED, | |||
MEMCACHED_FETCH_NOTFINISHED, | MEMCACHED_FETCH_NOTFINISHED, | |||
MEMCACHED_TIMEOUT, | MEMCACHED_TIMEOUT, | |||
MEMCACHED_BUFFERED, | MEMCACHED_BUFFERED, | |||
MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */ | MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */ | |||
} memcached_return; | } memcached_return; | |||
typedef struct memcached_st memcached_st; | ||||
typedef struct memcached_stat_st memcached_stat_st; | ||||
typedef struct memcached_result_st memcached_result_st; | ||||
typedef struct memcached_string_st memcached_string_st; | ||||
typedef struct memcached_server_st memcached_server_st; | ||||
typedef memcached_return (*memcached_clone_func)(memcached_st *parent, memc | ||||
ached_st *clone); | ||||
typedef memcached_return (*memcached_cleanup_func)(memcached_st *ptr); | ||||
typedef void (*memcached_free_function)(memcached_st *ptr, void *mem); | ||||
typedef void *(*memcached_malloc_function)(memcached_st *ptr, const size_t | ||||
size); | ||||
typedef void *(*memcached_realloc_function)(memcached_st *ptr, void *mem, c | ||||
onst size_t size); | ||||
typedef enum { | typedef enum { | |||
MEMCACHED_DISTRIBUTION_MODULA, | MEMCACHED_DISTRIBUTION_MODULA, | |||
MEMCACHED_DISTRIBUTION_CONSISTENT, | MEMCACHED_DISTRIBUTION_CONSISTENT, | |||
} memcached_server_distribution; | } memcached_server_distribution; | |||
typedef enum { | typedef enum { | |||
MEMCACHED_BEHAVIOR_NO_BLOCK, | MEMCACHED_BEHAVIOR_NO_BLOCK, | |||
MEMCACHED_BEHAVIOR_TCP_NODELAY, | MEMCACHED_BEHAVIOR_TCP_NODELAY, | |||
MEMCACHED_BEHAVIOR_HASH, | MEMCACHED_BEHAVIOR_HASH, | |||
MEMCACHED_BEHAVIOR_KETAMA, | MEMCACHED_BEHAVIOR_KETAMA, | |||
skipping to change at line 97 | skipping to change at line 105 | |||
MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, | MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, | |||
MEMCACHED_BEHAVIOR_CACHE_LOOKUPS, | MEMCACHED_BEHAVIOR_CACHE_LOOKUPS, | |||
MEMCACHED_BEHAVIOR_SUPPORT_CAS, | MEMCACHED_BEHAVIOR_SUPPORT_CAS, | |||
MEMCACHED_BEHAVIOR_POLL_TIMEOUT, | MEMCACHED_BEHAVIOR_POLL_TIMEOUT, | |||
MEMCACHED_BEHAVIOR_DISTRIBUTION, | MEMCACHED_BEHAVIOR_DISTRIBUTION, | |||
MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, | MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, | |||
MEMCACHED_BEHAVIOR_USER_DATA, | MEMCACHED_BEHAVIOR_USER_DATA, | |||
} memcached_behavior; | } memcached_behavior; | |||
typedef enum { | typedef enum { | |||
MEMCACHED_CALLBACK_USER_DATA, | ||||
MEMCACHED_CALLBACK_CLEANUP_FUNCTION, | ||||
MEMCACHED_CALLBACK_CLONE_FUNCTION, | ||||
MEMCACHED_CALLBACK_MALLOC_FUNCTION, | ||||
MEMCACHED_CALLBACK_REALLOC_FUNCTION, | ||||
MEMCACHED_CALLBACK_FREE_FUNCTION, | ||||
} memcached_callback; | ||||
typedef enum { | ||||
MEMCACHED_HASH_DEFAULT= 0, | MEMCACHED_HASH_DEFAULT= 0, | |||
MEMCACHED_HASH_MD5, | MEMCACHED_HASH_MD5, | |||
MEMCACHED_HASH_CRC, | MEMCACHED_HASH_CRC, | |||
MEMCACHED_HASH_FNV1_64, | MEMCACHED_HASH_FNV1_64, | |||
MEMCACHED_HASH_FNV1A_64, | MEMCACHED_HASH_FNV1A_64, | |||
MEMCACHED_HASH_FNV1_32, | MEMCACHED_HASH_FNV1_32, | |||
MEMCACHED_HASH_FNV1A_32, | MEMCACHED_HASH_FNV1A_32, | |||
MEMCACHED_HASH_KETAMA, | MEMCACHED_HASH_KETAMA, | |||
MEMCACHED_HASH_HSIEH, | MEMCACHED_HASH_HSIEH, | |||
} memcached_hash; | } memcached_hash; | |||
skipping to change at line 125 | skipping to change at line 142 | |||
typedef enum { | typedef enum { | |||
MEMCACHED_NOT_ALLOCATED, | MEMCACHED_NOT_ALLOCATED, | |||
MEMCACHED_ALLOCATED, | MEMCACHED_ALLOCATED, | |||
MEMCACHED_USED, | MEMCACHED_USED, | |||
} memcached_allocated; | } memcached_allocated; | |||
struct memcached_server_st { | struct memcached_server_st { | |||
char hostname[MEMCACHED_MAX_HOST_LENGTH]; | char hostname[MEMCACHED_MAX_HOST_LENGTH]; | |||
unsigned int port; | unsigned int port; | |||
int fd; | int fd; | |||
int cached_errno; | ||||
unsigned int cursor_active; | unsigned int cursor_active; | |||
char write_buffer[MEMCACHED_MAX_BUFFER]; | char write_buffer[MEMCACHED_MAX_BUFFER]; | |||
size_t write_buffer_offset; | size_t write_buffer_offset; | |||
char *write_ptr; | ||||
char read_buffer[MEMCACHED_MAX_BUFFER]; | char read_buffer[MEMCACHED_MAX_BUFFER]; | |||
size_t read_data_length; | size_t read_data_length; | |||
size_t read_buffer_length; | size_t read_buffer_length; | |||
char *read_ptr; | char *read_ptr; | |||
memcached_allocated sockaddr_inited; | memcached_allocated sockaddr_inited; | |||
struct addrinfo *address_info; | struct addrinfo *address_info; | |||
memcached_connection type; | memcached_connection type; | |||
uint8_t major_version; | uint8_t major_version; | |||
uint8_t minor_version; | uint8_t minor_version; | |||
uint8_t micro_version; | uint8_t micro_version; | |||
uint16_t count; | uint16_t count; | |||
memcached_st *root; | ||||
}; | }; | |||
struct memcached_stat_st { | struct memcached_stat_st { | |||
uint32_t pid; | uint32_t pid; | |||
uint32_t uptime; | uint32_t uptime; | |||
uint32_t threads; | uint32_t threads; | |||
uint32_t time; | uint32_t time; | |||
uint32_t pointer_size; | uint32_t pointer_size; | |||
uint32_t rusage_user_seconds; | uint32_t rusage_user_seconds; | |||
uint32_t rusage_user_microseconds; | uint32_t rusage_user_microseconds; | |||
skipping to change at line 166 | skipping to change at line 184 | |||
uint32_t total_connections; | uint32_t total_connections; | |||
uint32_t connection_structures; | uint32_t connection_structures; | |||
uint64_t bytes; | uint64_t bytes; | |||
uint64_t cmd_get; | uint64_t cmd_get; | |||
uint64_t cmd_set; | uint64_t cmd_set; | |||
uint64_t get_hits; | uint64_t get_hits; | |||
uint64_t get_misses; | uint64_t get_misses; | |||
uint64_t evictions; | uint64_t evictions; | |||
uint64_t bytes_read; | uint64_t bytes_read; | |||
uint64_t bytes_written; | uint64_t bytes_written; | |||
char version[MEMCACHED_VERSION_STRING]; | char version[MEMCACHED_VERSION_STRING_LENGTH]; | |||
}; | }; | |||
struct memcached_string_st { | struct memcached_string_st { | |||
memcached_st *root; | memcached_st *root; | |||
memcached_allocated is_allocated; | memcached_allocated is_allocated; | |||
char *string; | char *string; | |||
char *end; | char *end; | |||
size_t current_size; | size_t current_size; | |||
size_t block_size; | size_t block_size; | |||
}; | }; | |||
skipping to change at line 194 | skipping to change at line 212 | |||
uint32_t flags; | uint32_t flags; | |||
uint64_t cas; | uint64_t cas; | |||
/* Add result callback function */ | /* Add result callback function */ | |||
}; | }; | |||
struct memcached_st { | struct memcached_st { | |||
memcached_allocated is_allocated; | memcached_allocated is_allocated; | |||
memcached_server_st *hosts; | memcached_server_st *hosts; | |||
unsigned int number_of_hosts; | unsigned int number_of_hosts; | |||
unsigned int cursor_server; | unsigned int cursor_server; | |||
char connected; | ||||
int cached_errno; | int cached_errno; | |||
unsigned long long flags; | uint32_t flags; | |||
int send_size; | int send_size; | |||
int recv_size; | int recv_size; | |||
int32_t poll_timeout; | int32_t poll_timeout; | |||
memcached_result_st result; | memcached_result_st result; | |||
memcached_hash hash; | memcached_hash hash; | |||
memcached_server_distribution distribution; | memcached_server_distribution distribution; | |||
void *user_data; | void *user_data; | |||
unsigned int wheel[MEMCACHED_WHEEL_SIZE]; | unsigned int wheel[MEMCACHED_WHEEL_SIZE]; | |||
memcached_clone_func on_clone; | ||||
memcached_cleanup_func on_cleanup; | ||||
memcached_free_function call_free; | ||||
memcached_malloc_function call_malloc; | ||||
memcached_realloc_function call_realloc; | ||||
#ifdef NOT_USED /* Future Use */ | #ifdef NOT_USED /* Future Use */ | |||
uint8_t replicas; | uint8_t replicas; | |||
memcached_return warning; | memcached_return warning; | |||
#endif | #endif | |||
}; | }; | |||
/* Public API */ | /* Public API */ | |||
const char * memcached_lib_version(void); | ||||
memcached_st *memcached_create(memcached_st *ptr); | memcached_st *memcached_create(memcached_st *ptr); | |||
void memcached_free(memcached_st *ptr); | void memcached_free(memcached_st *ptr); | |||
memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr); | memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr); | |||
memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_ length, | memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_ length, | |||
time_t expiration); | time_t expiration); | |||
memcached_return memcached_increment(memcached_st *ptr, | memcached_return memcached_increment(memcached_st *ptr, | |||
char *key, size_t key_length, | char *key, size_t key_length, | |||
uint32_t offset, | uint32_t offset, | |||
uint64_t *value); | uint64_t *value); | |||
skipping to change at line 287 | skipping to change at line 311 | |||
memcached_return *error); | memcached_return *error); | |||
memcached_result_st *memcached_fetch_result(memcached_st *ptr, | memcached_result_st *memcached_fetch_result(memcached_st *ptr, | |||
memcached_result_st *result, | memcached_result_st *result, | |||
memcached_return *error); | memcached_return *error); | |||
/* Server Public functions */ | /* Server Public functions */ | |||
#define memcached_server_count(A) (A)->number_of_hosts | #define memcached_server_count(A) (A)->number_of_hosts | |||
#define memcached_server_name(A,B) (B).hostname | #define memcached_server_name(A,B) (B).hostname | |||
#define memcached_server_port(A,B) (B).port | #define memcached_server_port(A,B) (B).port | |||
#define memcached_server_list(A) (A)->hosts | #define memcached_server_list(A) (A)->hosts | |||
#define memcached_server_response_count(A,B) (A)->hosts[B].cursor_active | #define memcached_server_response_count(A) (A)->cursor_active | |||
memcached_return memcached_server_add_udp(memcached_st *ptr, | memcached_return memcached_server_add_udp(memcached_st *ptr, | |||
char *hostname, | char *hostname, | |||
unsigned int port); | unsigned int port); | |||
memcached_return memcached_server_add_unix_socket(memcached_st *ptr, | memcached_return memcached_server_add_unix_socket(memcached_st *ptr, | |||
char *filename); | char *filename); | |||
memcached_return memcached_server_add(memcached_st *ptr, char *hostname, | memcached_return memcached_server_add(memcached_st *ptr, char *hostname, | |||
unsigned int port); | unsigned int port); | |||
void memcached_server_list_free(memcached_server_st *ptr); | void memcached_server_list_free(memcached_server_st *ptr); | |||
memcached_return memcached_server_push(memcached_st *ptr, memcached_server_ st *list); | memcached_return memcached_server_push(memcached_st *ptr, memcached_server_ st *list); | |||
skipping to change at line 369 | skipping to change at line 393 | |||
char *key, size_t key_length, | char *key, size_t key_length, | |||
char *value, size_t value_length, | char *value, size_t value_length, | |||
time_t expiration, | time_t expiration, | |||
uint32_t flags, | uint32_t flags, | |||
uint64_t cas); | uint64_t cas); | |||
memcached_return memcached_delete_by_key(memcached_st *ptr, | memcached_return memcached_delete_by_key(memcached_st *ptr, | |||
char *master_key, size_t master_ke y_length, | char *master_key, size_t master_ke y_length, | |||
char *key, size_t key_length, | char *key, size_t key_length, | |||
time_t expiration); | time_t expiration); | |||
memcached_return memcached_mdelete(memcached_st *ptr, | ||||
char **key, size_t *key_length, | ||||
unsigned int number_of_keys, | ||||
time_t expiration); | ||||
memcached_return memcached_mdelete_by_key(memcached_st *ptr, | ||||
char *master_key, size_t master_k | ||||
ey_length, | ||||
char **key, size_t *key_length, | ||||
unsigned int number_of_keys, | ||||
time_t expiration); | ||||
memcached_return memcached_fetch_execute(memcached_st *ptr, | memcached_return memcached_fetch_execute(memcached_st *ptr, | |||
unsigned int (*callback[])(mem cached_st *ptr, memcached_result_st *result, void *context), | unsigned int (*callback[])(mem cached_st *ptr, memcached_result_st *result, void *context), | |||
void *context, | void *context, | |||
unsigned int number_of_callbac ks | unsigned int number_of_callbac ks | |||
); | ); | |||
memcached_return memcached_callback_set(memcached_st *ptr, | ||||
memcached_callback flag, | ||||
void *data); | ||||
void *memcached_callback_get(memcached_st *ptr, | ||||
memcached_callback flag, | ||||
memcached_return *error); | ||||
/* Result Struct */ | /* Result Struct */ | |||
void memcached_result_free(memcached_result_st *result); | void memcached_result_free(memcached_result_st *result); | |||
memcached_result_st *memcached_result_create(memcached_st *ptr, | memcached_result_st *memcached_result_create(memcached_st *ptr, | |||
memcached_result_st *result); | memcached_result_st *result); | |||
#define memcached_result_key_value(A) (A)->key | #define memcached_result_key_value(A) (A)->key | |||
#define memcached_result_key_length(A) (A)->key_length | #define memcached_result_key_length(A) (A)->key_length | |||
#ifdef FIX | #ifdef FIX | |||
#define memcached_result_value(A) memcached_string_value((A)->value) | #define memcached_result_value(A) memcached_string_value((A)->value) | |||
#define memcached_result_length(A) memcached_string_length((A)->value) | #define memcached_result_length(A) memcached_string_length((A)->value) | |||
#else | #else | |||
End of changes. 18 change blocks. | ||||
27 lines changed or deleted | 49 lines changed or added | |||