memcached.h | memcached.h | |||
---|---|---|---|---|
skipping to change at line 16 | skipping to change at line 16 | |||
* | * | |||
* Author: Brian Aker | * Author: Brian Aker | |||
*/ | */ | |||
#ifndef __MEMCACHED_H__ | #ifndef __MEMCACHED_H__ | |||
#define __MEMCACHED_H__ | #define __MEMCACHED_H__ | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <stdint.h> | #include <stdint.h> | |||
#include <sys/types.h> | #include <sys/types.h> | |||
#include <netinet/in.h> | ||||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
typedef struct memcached_st memcached_st; | typedef struct memcached_st memcached_st; | |||
typedef struct memcached_stat_st memcached_stat_st; | typedef struct memcached_stat_st memcached_stat_st; | |||
typedef struct memcached_result_st memcached_result_st; | typedef struct memcached_result_st memcached_result_st; | |||
typedef struct memcached_string_st memcached_string_st; | typedef struct memcached_string_st memcached_string_st; | |||
typedef struct memcached_server_st memcached_server_st; | typedef struct memcached_server_st memcached_server_st; | |||
#define MEMCACHED_VERSION_STRING 12 | ||||
#define MEMCACHED_DEFAULT_PORT 11211 | #define MEMCACHED_DEFAULT_PORT 11211 | |||
#define MEMCACHED_DEFAULT_COMMAND_SIZE 350 | #define MEMCACHED_DEFAULT_COMMAND_SIZE 350 | |||
#define SMALL_STRING_LEN 1024 | #define SMALL_STRING_LEN 1024 | |||
#define HUGE_STRING_LEN 8196 | #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 HUGE_STRING_LEN | |||
typedef enum { | typedef enum { | |||
MEMCACHED_SUCCESS, | MEMCACHED_SUCCESS, | |||
MEMCACHED_FAILURE, | MEMCACHED_FAILURE, | |||
skipping to change at line 63 | skipping to change at line 65 | |||
MEMCACHED_PARTIAL_READ, | MEMCACHED_PARTIAL_READ, | |||
MEMCACHED_SOME_ERRORS, | MEMCACHED_SOME_ERRORS, | |||
MEMCACHED_NO_SERVERS, | MEMCACHED_NO_SERVERS, | |||
MEMCACHED_END, | MEMCACHED_END, | |||
MEMCACHED_DELETED, | MEMCACHED_DELETED, | |||
MEMCACHED_VALUE, | MEMCACHED_VALUE, | |||
MEMCACHED_STAT, | MEMCACHED_STAT, | |||
MEMCACHED_ERRNO, | MEMCACHED_ERRNO, | |||
MEMCACHED_FAIL_UNIX_SOCKET, | MEMCACHED_FAIL_UNIX_SOCKET, | |||
MEMCACHED_NOT_SUPPORTED, | MEMCACHED_NOT_SUPPORTED, | |||
MEMCACHED_NO_KEY_PROVIDED, | ||||
MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */ | MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */ | |||
} memcached_return; | } memcached_return; | |||
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, | |||
MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, | MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, | |||
MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, | MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, | |||
skipping to change at line 104 | skipping to change at line 107 | |||
MEMCACHED_NOT_ALLOCATED, | MEMCACHED_NOT_ALLOCATED, | |||
MEMCACHED_ALLOCATED, | MEMCACHED_ALLOCATED, | |||
} memcached_allocated; | } memcached_allocated; | |||
struct memcached_server_st { | struct memcached_server_st { | |||
char *hostname; | char *hostname; | |||
unsigned int port; | unsigned int port; | |||
int fd; | int fd; | |||
unsigned int stack_responses; | unsigned int stack_responses; | |||
unsigned int cursor_active; | unsigned int cursor_active; | |||
char write_buffer[MEMCACHED_MAX_BUFFER]; | ||||
size_t write_buffer_offset; | ||||
char *write_ptr; | ||||
char read_buffer[MEMCACHED_MAX_BUFFER]; | ||||
size_t read_buffer_length; | ||||
char *read_ptr; | ||||
struct sockaddr_in servAddr; | ||||
memcached_connection type; | memcached_connection type; | |||
uint8_t major_version; | ||||
uint8_t minor_version; | ||||
uint8_t micro_version; | ||||
}; | }; | |||
struct memcached_stat_st { | struct memcached_stat_st { | |||
unsigned int pid; | unsigned int pid; | |||
unsigned int uptime; | unsigned int uptime; | |||
unsigned int threads; | unsigned int threads; | |||
time_t time; | time_t time; | |||
char version[8]; | char version[MEMCACHED_VERSION_STRING]; | |||
unsigned int pointer_size; | unsigned int pointer_size; | |||
unsigned int rusage_user; | unsigned int rusage_user; | |||
unsigned int rusage_system; | unsigned int rusage_system; | |||
unsigned int rusage_user_seconds; | unsigned int rusage_user_seconds; | |||
unsigned int rusage_user_microseconds; | unsigned int rusage_user_microseconds; | |||
unsigned int rusage_system_seconds; | unsigned int rusage_system_seconds; | |||
unsigned int rusage_system_microseconds; | unsigned int rusage_system_microseconds; | |||
unsigned int curr_items; | unsigned int curr_items; | |||
unsigned int total_items; | unsigned int total_items; | |||
unsigned long long bytes; | unsigned long long bytes; | |||
skipping to change at line 160 | skipping to change at line 173 | |||
memcached_string_st value; | memcached_string_st value; | |||
uint16_t flags; | uint16_t flags; | |||
uint64_t cas; | uint64_t cas; | |||
}; | }; | |||
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 read_buffer[MEMCACHED_MAX_BUFFER]; | ||||
size_t read_buffer_length; | ||||
char *read_ptr; | ||||
char write_buffer[MEMCACHED_MAX_BUFFER]; | ||||
size_t write_buffer_offset; | ||||
char connected; | char connected; | |||
int cached_errno; | int cached_errno; | |||
unsigned long long flags; | unsigned long long flags; | |||
int send_size; | int send_size; | |||
int recv_size; | int recv_size; | |||
memcached_string_st result_buffer; | memcached_string_st result_buffer; | |||
memcached_hash hash; | memcached_hash hash; | |||
memcached_return warning; /* Future Use */ | memcached_return warning; /* Future Use */ | |||
}; | }; | |||
/* Public API */ | /* Public API */ | |||
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, | |||
unsigned int offset, | unsigned int offset, | |||
unsigned int *value); | uint64_t *value); | |||
memcached_return memcached_decrement(memcached_st *ptr, | memcached_return memcached_decrement(memcached_st *ptr, | |||
char *key, size_t key_length, | char *key, size_t key_length, | |||
unsigned int offset, | unsigned int offset, | |||
unsigned int *value); | uint64_t *value); | |||
void memcached_stat_free(memcached_st *, memcached_stat_st *); | void memcached_stat_free(memcached_st *, memcached_stat_st *); | |||
memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_ return *error); | memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_ return *error); | |||
memcached_return memcached_stat_servername(memcached_stat_st *stat, char *a rgs, | memcached_return memcached_stat_servername(memcached_stat_st *stat, char *a rgs, | |||
char *hostname, unsigned int por t); | char *hostname, unsigned int por t); | |||
memcached_return memcached_flush(memcached_st *ptr, time_t expiration); | memcached_return memcached_flush(memcached_st *ptr, time_t expiration); | |||
memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbos ity); | memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbos ity); | |||
void memcached_quit(memcached_st *ptr); | void memcached_quit(memcached_st *ptr); | |||
char *memcached_strerror(memcached_st *ptr, memcached_return rc); | char *memcached_strerror(memcached_st *ptr, memcached_return rc); | |||
memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavi or flag, void *data); | memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavi or flag, void *data); | |||
unsigned long long memcached_behavior_get(memcached_st *ptr, memcached_beha vior flag); | unsigned long long memcached_behavior_get(memcached_st *ptr, memcached_beha vior flag); | |||
skipping to change at line 214 | skipping to change at line 222 | |||
time_t expiration, | time_t expiration, | |||
uint16_t flags); | uint16_t flags); | |||
memcached_return memcached_add(memcached_st *ptr, char *key, size_t key_len gth, | memcached_return memcached_add(memcached_st *ptr, char *key, size_t key_len gth, | |||
char *value, size_t value_length, | char *value, size_t value_length, | |||
time_t expiration, | time_t expiration, | |||
uint16_t flags); | uint16_t flags); | |||
memcached_return memcached_replace(memcached_st *ptr, char *key, size_t key _length, | memcached_return memcached_replace(memcached_st *ptr, char *key, size_t key _length, | |||
char *value, size_t value_length, | char *value, size_t value_length, | |||
time_t expiration, | time_t expiration, | |||
uint16_t flags); | uint16_t flags); | |||
memcached_return memcached_append(memcached_st *ptr, | ||||
char *key, size_t key_length, | ||||
char *value, size_t value_length, | ||||
time_t expiration, | ||||
uint16_t flags); | ||||
memcached_return memcached_prepend(memcached_st *ptr, | ||||
char *key, size_t key_length, | ||||
char *value, size_t value_length, | ||||
time_t expiration, | ||||
uint16_t flags); | ||||
memcached_return memcached_cas(memcached_st *ptr, | ||||
char *key, size_t key_length, | ||||
char *value, size_t value_length, | ||||
time_t expiration, | ||||
uint16_t flags, | ||||
uint64_t cas); | ||||
/* Get functions */ | /* Get functions */ | |||
char *memcached_get(memcached_st *ptr, char *key, size_t key_length, | char *memcached_get(memcached_st *ptr, char *key, size_t key_length, | |||
size_t *value_length, | size_t *value_length, | |||
uint16_t *flags, | uint16_t *flags, | |||
memcached_return *error); | memcached_return *error); | |||
memcached_return memcached_mget(memcached_st *ptr, | memcached_return memcached_mget(memcached_st *ptr, | |||
char **keys, size_t *key_length, | char **keys, size_t *key_length, | |||
unsigned int number_of_keys); | unsigned int number_of_keys); | |||
char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, | char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, | |||
skipping to change at line 237 | skipping to change at line 261 | |||
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].stack_responses | #define memcached_server_response_count(A,B) A->hosts[B].stack_responses | |||
memcached_return memcached_server_add_udp(memcached_st *ptr, | ||||
char *hostname, | ||||
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); | |||
memcached_server_st *memcached_server_list_append(memcached_server_st *ptr, | memcached_server_st *memcached_server_list_append(memcached_server_st *ptr, | |||
char *hostname, unsigned int p ort, | char *hostname, unsigned int p ort, | |||
memcached_return *error); | memcached_return *error); | |||
End of changes. 11 change blocks. | ||||
8 lines changed or deleted | 35 lines changed or added | |||