memcached.h | memcached.h | |||
---|---|---|---|---|
skipping to change at line 37 | skipping to change at line 37 | |||
#include <libmemcached/memcached_get.h> | #include <libmemcached/memcached_get.h> | |||
#include <libmemcached/memcached_server.h> | #include <libmemcached/memcached_server.h> | |||
#include <libmemcached/memcached_string.h> | #include <libmemcached/memcached_string.h> | |||
#include <libmemcached/memcached_result.h> | #include <libmemcached/memcached_result.h> | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
/* These are Private and should not be used by applications */ | /* These are Private and should not be used by applications */ | |||
#define MEMCACHED_VERSION_STRING_LENGTH 12 | #define MEMCACHED_VERSION_STRING_LENGTH 24 | |||
/* string value */ | /* string value */ | |||
struct memcached_continuum_item_st { | struct memcached_continuum_item_st { | |||
uint32_t index; | uint32_t index; | |||
uint32_t value; | uint32_t value; | |||
}; | }; | |||
#define LIBMEMCACHED_VERSION_STRING "0.28" | #define LIBMEMCACHED_VERSION_STRING "0.29" | |||
struct memcached_analysis_st { | struct memcached_analysis_st { | |||
uint64_t most_used_bytes; | uint64_t most_used_bytes; | |||
uint64_t least_remaining_bytes; | uint64_t least_remaining_bytes; | |||
uint32_t average_item_size; | uint32_t average_item_size; | |||
uint32_t longest_uptime; | uint32_t longest_uptime; | |||
uint32_t least_free_server; | uint32_t least_free_server; | |||
uint32_t most_consumed_server; | uint32_t most_consumed_server; | |||
uint32_t oldest_server; | uint32_t oldest_server; | |||
double pool_hit_ratio; | double pool_hit_ratio; | |||
skipping to change at line 120 | skipping to change at line 120 | |||
memcached_trigger_delete_key delete_trigger; | memcached_trigger_delete_key delete_trigger; | |||
char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE]; | char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE]; | |||
size_t prefix_key_length; | size_t prefix_key_length; | |||
memcached_hash hash_continuum; | memcached_hash hash_continuum; | |||
uint32_t continuum_points_counter; | uint32_t continuum_points_counter; | |||
int32_t snd_timeout; | int32_t snd_timeout; | |||
int32_t rcv_timeout; | int32_t rcv_timeout; | |||
uint32_t server_failure_limit; | uint32_t server_failure_limit; | |||
uint32_t io_msg_watermark; | uint32_t io_msg_watermark; | |||
uint32_t io_bytes_watermark; | uint32_t io_bytes_watermark; | |||
uint32_t io_key_prefetch; | ||||
time_t next_distribution_rebuild; | ||||
}; | }; | |||
/* Public API */ | /* Public API */ | |||
const char * memcached_lib_version(void); | 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, const char *key, size_ t key_length, | memcached_return memcached_delete(memcached_st *ptr, const 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, | |||
const char *key, size_t key_length, | const char *key, size_t key_length, | |||
uint32_t offset, | uint32_t offset, | |||
uint64_t *value); | uint64_t *value); | |||
memcached_return memcached_decrement(memcached_st *ptr, | memcached_return memcached_decrement(memcached_st *ptr, | |||
const char *key, size_t key_length, | const char *key, size_t key_length, | |||
uint32_t offset, | uint32_t offset, | |||
uint64_t *value); | uint64_t *value); | |||
memcached_return memcached_increment_with_initial(memcached_st *ptr, | ||||
const char *key, | ||||
size_t key_length, | ||||
uint64_t offset, | ||||
uint64_t initial, | ||||
time_t expiration, | ||||
uint64_t *value); | ||||
memcached_return memcached_decrement_with_initial(memcached_st *ptr, | ||||
const char *key, | ||||
size_t key_length, | ||||
uint64_t offset, | ||||
uint64_t initial, | ||||
time_t expiration, | ||||
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, uint64_t data); | memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavi or flag, uint64_t data); | |||
uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior flag) ; | uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior flag) ; | |||
End of changes. 4 change blocks. | ||||
2 lines changed or deleted | 18 lines changed or added | |||
memcached.hh | memcached.hh | |||
---|---|---|---|---|
#ifdef USE_PRAGMA_INTERFACE | #include "libmemcached/memcached.h" | |||
#pragma interface /* gcc class implementation */ | ||||
#endif | ||||
#include <memcached.h> | ||||
#include <string.h> | #include <string.h> | |||
#include <stdio.h> | #include <stdio.h> | |||
class Memcached | class Memcached | |||
{ | { | |||
memcached_st memc; | memcached_st memc; | |||
memcached_result_st result; | memcached_result_st result; | |||
public: | public: | |||
Memcached() | Memcached() : memc(), result() | |||
{ | { | |||
memcached_create(&memc); | memcached_create(&memc); | |||
} | } | |||
Memcached(memcached_st *clone) | Memcached(memcached_st *clone) : memc(), result() | |||
{ | { | |||
memcached_clone(&memc, clone); | memcached_clone(&memc, clone); | |||
} | } | |||
char *fetch (char *key, size_t *key_length, size_t *value_length) | char *fetch (char *key, size_t *key_length, size_t *value_length) | |||
{ | { | |||
uint32_t flags; | uint32_t flags; | |||
memcached_return rc; | memcached_return rc; | |||
return memcached_fetch(&memc, key, key_length, | return memcached_fetch(&memc, key, key_length, | |||
value_length, &flags, &rc); | value_length, &flags, &rc); | |||
skipping to change at line 64 | skipping to change at line 60 | |||
unsigned int number_of_keys) | unsigned int number_of_keys) | |||
{ | { | |||
return memcached_mget(&memc, keys, key_length, number_of_keys); | return memcached_mget(&memc, keys, key_length, number_of_keys); | |||
} | } | |||
memcached_return set(const char *key, const char *value, size_t value_len gth) | memcached_return set(const char *key, const char *value, size_t value_len gth) | |||
{ | { | |||
return memcached_set(&memc, key, strlen(key), | return memcached_set(&memc, key, strlen(key), | |||
value, value_length, | value, value_length, | |||
(time_t)0, (uint32_t)0); | time_t(0), uint32_t(0)); | |||
} | } | |||
memcached_return set_by_key(const char *master_key, const char *key, | memcached_return set_by_key(const char *master_key, const char *key, | |||
const char *value, size_t value_length) | const char *value, size_t value_length) | |||
{ | { | |||
return memcached_set_by_key(&memc, master_key, strlen(master_key), | return memcached_set_by_key(&memc, master_key, strlen(master_key), | |||
key, strlen(key), | key, strlen(key), | |||
value, value_length, | value, value_length, | |||
(time_t)0, | time_t(0), | |||
(uint32_t)0 ); | uint32_t(0) ); | |||
} | } | |||
memcached_return | memcached_return | |||
increment(const char *key, unsigned int offset, uint64_t *value) | increment(const char *key, unsigned int offset, uint64_t *value) | |||
{ | { | |||
return memcached_increment(&memc, key, strlen(key), | return memcached_increment(&memc, key, strlen(key), | |||
offset, value); | offset, value); | |||
} | } | |||
memcached_return | memcached_return | |||
decrement(const char *key, unsigned int offset, uint64_t *value) | decrement(const char *key, unsigned int offset, uint64_t *value) | |||
{ | { | |||
return memcached_decrement(&memc, key, strlen(key), | return memcached_decrement(&memc, key, strlen(key), | |||
offset, value); | offset, value); | |||
} | } | |||
memcached_return add(const char *key, const char *value, size_t value_len gth) | memcached_return add(const char *key, const char *value, size_t value_len gth) | |||
{ | { | |||
return memcached_add(&memc, key, strlen(key), | return memcached_add(&memc, key, strlen(key), value, value_length, 0, 0 | |||
value, value_length, | ); | |||
(time_t)0, (uint32_t)0); | ||||
} | } | |||
memcached_return add_by_key(const char *master_key, const char *key, | memcached_return add_by_key(const char *master_key, const char *key, | |||
const char *value, size_t value_length) | const char *value, size_t value_length) | |||
{ | { | |||
return memcached_add_by_key(&memc, master_key, strlen(master_key), | return memcached_add_by_key(&memc, master_key, strlen(master_key), | |||
key, strlen(key), | key, strlen(key), | |||
value, value_length, | value, value_length, | |||
(time_t)0, (uint32_t)0); | 0, 0); | |||
} | } | |||
memcached_return replace(const char *key, const char *value, | memcached_return replace(const char *key, const char *value, | |||
size_t value_length) | size_t value_length) | |||
{ | { | |||
return memcached_replace(&memc, key, strlen(key), | return memcached_replace(&memc, key, strlen(key), | |||
value, value_length, | value, value_length, | |||
(time_t)0, (uint32_t)0); | 0, 0); | |||
} | } | |||
memcached_return replace_by_key(const char *master_key, const char *key, | memcached_return replace_by_key(const char *master_key, const char *key, | |||
const char *value, size_t value_length) | const char *value, size_t value_length) | |||
{ | { | |||
return memcached_replace_by_key(&memc, master_key, strlen(master_key), | return memcached_replace_by_key(&memc, master_key, strlen(master_key), | |||
key, strlen(key), | key, strlen(key), | |||
value, value_length, | value, value_length, 0, 0); | |||
(time_t)0, (uint32_t)0); | ||||
} | } | |||
memcached_return prepend(const char *key, const char *value, | memcached_return prepend(const char *key, const char *value, | |||
size_t value_length) | size_t value_length) | |||
{ | { | |||
return memcached_prepend(&memc, key, strlen(key), | return memcached_prepend(&memc, key, strlen(key), | |||
value, value_length, | value, value_length, 0, 0); | |||
(time_t)0, | ||||
(uint32_t)0); | ||||
} | } | |||
memcached_return prepend_by_key(const char *master_key, const char *key, | memcached_return prepend_by_key(const char *master_key, const char *key, | |||
const char *value, size_t value_length) | const char *value, size_t value_length) | |||
{ | { | |||
return memcached_prepend_by_key(&memc, master_key, strlen(master_key), | return memcached_prepend_by_key(&memc, master_key, strlen(master_key), | |||
key, strlen(key), | key, strlen(key), | |||
value, value_length, | value, value_length, | |||
(time_t)0, | 0, | |||
(uint32_t)0); | 0); | |||
} | } | |||
memcached_return append(const char *key, const char *value, | memcached_return append(const char *key, const char *value, | |||
size_t value_length) | size_t value_length) | |||
{ | { | |||
return memcached_append(&memc, key, strlen(key), | return memcached_append(&memc, key, strlen(key), | |||
value, value_length, | value, value_length, 0, 0); | |||
(time_t)0, | ||||
(uint32_t)0); | ||||
} | } | |||
memcached_return append_by_key(const char *master_key, const char *key, | memcached_return append_by_key(const char *master_key, const char *key, | |||
const char *value, size_t value_length) | const char *value, size_t value_length) | |||
{ | { | |||
return memcached_append_by_key(&memc, | return memcached_append_by_key(&memc, | |||
master_key, strlen(master_key), | master_key, strlen(master_key), | |||
key, strlen(key), | key, strlen(key), | |||
value, value_length, | value, value_length, 0, 0); | |||
(time_t)0, | ||||
(uint32_t)0); | ||||
} | } | |||
memcached_return cas(const char *key, const char *value, | memcached_return cas(const char *key, const char *value, | |||
size_t value_length, uint64_t cas) | size_t value_length, uint64_t cas) | |||
{ | { | |||
return memcached_cas(&memc, key, strlen(key), | return memcached_cas(&memc, key, strlen(key), | |||
value, value_length, | value, value_length, 0, 0, cas); | |||
(time_t)0, | ||||
(uint32_t)0, | ||||
cas); | ||||
} | } | |||
memcached_return cas_by_key(const char *master_key, const char *key, | memcached_return cas_by_key(const char *master_key, const char *key, | |||
const char *value, size_t value_length, | const char *value, size_t value_length, | |||
uint64_t cas) | uint64_t cas) | |||
{ | { | |||
return memcached_cas_by_key(&memc, | return memcached_cas_by_key(&memc, | |||
master_key, strlen(master_key), | master_key, strlen(master_key), | |||
key, strlen(key), | key, strlen(key), | |||
value, value_length, | value, value_length, | |||
(time_t)0, | 0, 0, cas); | |||
(uint32_t)0, | ||||
cas); | ||||
} | } | |||
// using 'remove' vs. 'delete' since 'delete' is a keyword | // using 'remove' vs. 'delete' since 'delete' is a keyword | |||
memcached_return remove(const char *key) | memcached_return remove(const char *key) | |||
{ | { | |||
return memcached_delete (&memc, key, strlen(key), (time_t)0); | return memcached_delete (&memc, key, strlen(key), 0); | |||
} | } | |||
memcached_return delete_by_key(const char *master_key, const char *key) | memcached_return delete_by_key(const char *master_key, const char *key) | |||
{ | { | |||
return memcached_delete_by_key(&memc, master_key, strlen(master_key), | return memcached_delete_by_key(&memc, master_key, strlen(master_key), | |||
key, strlen(key), (time_t)0); | key, strlen(key), 0); | |||
} | } | |||
~Memcached() | ~Memcached() | |||
{ | { | |||
memcached_free(&memc); | memcached_free(&memc); | |||
} | } | |||
}; | }; | |||
End of changes. 17 change blocks. | ||||
37 lines changed or deleted | 20 lines changed or added | |||
memcached_constants.h | memcached_constants.h | |||
---|---|---|---|---|
skipping to change at line 29 | skipping to change at line 29 | |||
#define MEMCACHED_MAX_BUFFER 8196 | #define MEMCACHED_MAX_BUFFER 8196 | |||
#define MEMCACHED_MAX_HOST_LENGTH 64 | #define MEMCACHED_MAX_HOST_LENGTH 64 | |||
#define MEMCACHED_MAX_HOST_SORT_LENGTH 86 /* Used for Ketama */ | #define MEMCACHED_MAX_HOST_SORT_LENGTH 86 /* Used for Ketama */ | |||
#define MEMCACHED_POINTS_PER_SERVER 100 | #define MEMCACHED_POINTS_PER_SERVER 100 | |||
#define MEMCACHED_POINTS_PER_SERVER_KETAMA 160 | #define MEMCACHED_POINTS_PER_SERVER_KETAMA 160 | |||
#define MEMCACHED_CONTINUUM_SIZE MEMCACHED_POINTS_PER_SERVER*100 /* This wo uld then set max hosts to 100 */ | #define MEMCACHED_CONTINUUM_SIZE MEMCACHED_POINTS_PER_SERVER*100 /* This wo uld then set max hosts to 100 */ | |||
#define MEMCACHED_STRIDE 4 | #define MEMCACHED_STRIDE 4 | |||
#define MEMCACHED_DEFAULT_TIMEOUT 1000 | #define MEMCACHED_DEFAULT_TIMEOUT 1000 | |||
#define MEMCACHED_CONTINUUM_ADDITION 10 /* How many extra slots we should b uild for in the continuum */ | #define MEMCACHED_CONTINUUM_ADDITION 10 /* How many extra slots we should b uild for in the continuum */ | |||
#define MEMCACHED_PREFIX_KEY_MAX_SIZE 128 | #define MEMCACHED_PREFIX_KEY_MAX_SIZE 128 | |||
#define MEMCACHED_EXPIRATION_NOT_ADD 0xffffffffU | ||||
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, | |||
skipping to change at line 65 | skipping to change at line 66 | |||
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, /* Deprecated. Use MEMCACHED_BAD_KEY_PROVIDED! */ | MEMCACHED_NO_KEY_PROVIDED, /* Deprecated. Use MEMCACHED_BAD_KEY_PROVIDED! */ | |||
MEMCACHED_FETCH_NOTFINISHED, | MEMCACHED_FETCH_NOTFINISHED, | |||
MEMCACHED_TIMEOUT, | MEMCACHED_TIMEOUT, | |||
MEMCACHED_BUFFERED, | MEMCACHED_BUFFERED, | |||
MEMCACHED_BAD_KEY_PROVIDED, | MEMCACHED_BAD_KEY_PROVIDED, | |||
MEMCACHED_INVALID_HOST_PROTOCOL, | MEMCACHED_INVALID_HOST_PROTOCOL, | |||
MEMCACHED_SERVER_MARKED_DEAD, | ||||
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_DISTRIBUTION_MODULA, | MEMCACHED_DISTRIBUTION_MODULA, | |||
MEMCACHED_DISTRIBUTION_CONSISTENT, | MEMCACHED_DISTRIBUTION_CONSISTENT, | |||
MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, | MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, | |||
MEMCACHED_DISTRIBUTION_RANDOM | MEMCACHED_DISTRIBUTION_RANDOM | |||
} memcached_server_distribution; | } memcached_server_distribution; | |||
skipping to change at line 100 | skipping to change at line 102 | |||
MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, | MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, | |||
MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, | MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, | |||
MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, | MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, | |||
MEMCACHED_BEHAVIOR_KETAMA_HASH, | MEMCACHED_BEHAVIOR_KETAMA_HASH, | |||
MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, | MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, | |||
MEMCACHED_BEHAVIOR_SND_TIMEOUT, | MEMCACHED_BEHAVIOR_SND_TIMEOUT, | |||
MEMCACHED_BEHAVIOR_RCV_TIMEOUT, | MEMCACHED_BEHAVIOR_RCV_TIMEOUT, | |||
MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, | MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, | |||
MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK, | MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK, | |||
MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, | MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, | |||
MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, | ||||
MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY, | MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY, | |||
MEMCACHED_BEHAVIOR_NOREPLY, | MEMCACHED_BEHAVIOR_NOREPLY, | |||
MEMCACHED_BEHAVIOR_USE_UDP | MEMCACHED_BEHAVIOR_USE_UDP, | |||
MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS | ||||
} memcached_behavior; | } memcached_behavior; | |||
typedef enum { | typedef enum { | |||
MEMCACHED_CALLBACK_PREFIX_KEY, | MEMCACHED_CALLBACK_PREFIX_KEY, | |||
MEMCACHED_CALLBACK_USER_DATA, | MEMCACHED_CALLBACK_USER_DATA, | |||
MEMCACHED_CALLBACK_CLEANUP_FUNCTION, | MEMCACHED_CALLBACK_CLEANUP_FUNCTION, | |||
MEMCACHED_CALLBACK_CLONE_FUNCTION, | MEMCACHED_CALLBACK_CLONE_FUNCTION, | |||
MEMCACHED_CALLBACK_MALLOC_FUNCTION, | MEMCACHED_CALLBACK_MALLOC_FUNCTION, | |||
MEMCACHED_CALLBACK_REALLOC_FUNCTION, | MEMCACHED_CALLBACK_REALLOC_FUNCTION, | |||
MEMCACHED_CALLBACK_FREE_FUNCTION, | MEMCACHED_CALLBACK_FREE_FUNCTION, | |||
End of changes. 4 change blocks. | ||||
1 lines changed or deleted | 5 lines changed or added | |||