| algorithm.h | | algorithm.h | |
| | | | |
| skipping to change at line 22 | | skipping to change at line 22 | |
| */ | | */ | |
| | | | |
| #ifndef HASHKIT_ALGORITHM_H | | #ifndef HASHKIT_ALGORITHM_H | |
| #define HASHKIT_ALGORITHM_H | | #define HASHKIT_ALGORITHM_H | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
|
| uint32_t hashkit_default(const char *key, size_t key_length); | | uint32_t libhashkit_one_at_a_time(const char *key, size_t key_length); | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
|
| uint32_t hashkit_fnv1_64(const char *key, size_t key_length); | | uint32_t libhashkit_fnv1_64(const char *key, size_t key_length); | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
|
| uint32_t hashkit_fnv1a_64(const char *key, size_t key_length); | | uint32_t libhashkit_fnv1a_64(const char *key, size_t key_length); | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
|
| uint32_t hashkit_fnv1_32(const char *key, size_t key_length); | | uint32_t libhashkit_fnv1_32(const char *key, size_t key_length); | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
|
| uint32_t hashkit_fnv1a_32(const char *key, size_t key_length); | | uint32_t libhashkit_fnv1a_32(const char *key, size_t key_length); | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
|
| uint32_t hashkit_crc32(const char *key, size_t key_length); | | uint32_t libhashkit_crc32(const char *key, size_t key_length); | |
| | | | |
| #ifdef HAVE_HSIEH_HASH | | #ifdef HAVE_HSIEH_HASH | |
| HASHKIT_API | | HASHKIT_API | |
|
| uint32_t hashkit_hsieh(const char *key, size_t key_length); | | uint32_t libhashkit_hsieh(const char *key, size_t key_length); | |
| #endif | | #endif | |
|
| | | | |
| | | HASHKIT_API | |
| | | uint32_t libhashkit_murmur(const char *key, size_t key_length); | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
|
| uint32_t hashkit_murmur(const char *key, size_t key_length); | | uint32_t libhashkit_jenkins(const char *key, size_t key_length); | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
|
| uint32_t hashkit_jenkins(const char *key, size_t key_length); | | uint32_t libhashkit_md5(const char *key, size_t key_length); | |
| | | | |
| | | HASHKIT_LOCAL | |
| | | uint32_t hashkit_one_at_a_time(const char *key, size_t key_length, void *co | |
| | | ntext); | |
| | | | |
| | | HASHKIT_LOCAL | |
| | | uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *context) | |
| | | ; | |
| | | | |
| | | HASHKIT_LOCAL | |
| | | uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context | |
| | | ); | |
| | | | |
| | | HASHKIT_LOCAL | |
| | | uint32_t hashkit_fnv1_32(const char *key, size_t key_length, void *context) | |
| | | ; | |
| | | | |
| | | HASHKIT_LOCAL | |
| | | uint32_t hashkit_fnv1a_32(const char *key, size_t key_length, void *context | |
| | | ); | |
| | | | |
| | | HASHKIT_LOCAL | |
| | | uint32_t hashkit_crc32(const char *key, size_t key_length, void *context); | |
| | | | |
| | | #ifdef HAVE_HSIEH_HASH | |
| | | HASHKIT_LOCAL | |
| | | uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context); | |
| | | #endif | |
| | | | |
| | | HASHKIT_LOCAL | |
| | | uint32_t hashkit_murmur(const char *key, size_t key_length, void *context); | |
| | | | |
| | | HASHKIT_LOCAL | |
| | | uint32_t hashkit_jenkins(const char *key, size_t key_length, void *context) | |
| | | ; | |
| | | | |
| | | HASHKIT_LOCAL | |
| | | uint32_t hashkit_md5(const char *key, size_t key_length, void *context); | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
|
| uint32_t hashkit_md5(const char *key, size_t key_length); | | void libhashkit_md5_signature(const unsigned char *key, size_t length, unsi
gned char *result); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif /* HASHKIT_ALGORITHM_H */ | | #endif /* HASHKIT_ALGORITHM_H */ | |
| | | | |
End of changes. 11 change blocks. |
| 10 lines changed or deleted | | 60 lines changed or added | |
|
| constants.h | | constants.h | |
| | | | |
| skipping to change at line 12 | | skipping to change at line 12 | |
| * Copyright (C) 2006-2009 Brian Aker | | * Copyright (C) 2006-2009 Brian Aker | |
| * All rights reserved. | | * All rights reserved. | |
| * | | * | |
| * Use and distribution licensed under the BSD license. See | | * Use and distribution licensed under the BSD license. See | |
| * the COPYING file in the parent directory for full text. | | * the COPYING file in the parent directory for full text. | |
| * | | * | |
| * Summary: Constants for libmemcached | | * Summary: Constants for libmemcached | |
| * | | * | |
| */ | | */ | |
| | | | |
|
| #ifndef __MEMCACHED_CONSTANTS_H__ | | #ifndef __LIBMEMCACHED_CONSTANTS_H__ | |
| #define __MEMCACHED_CONSTANTS_H__ | | #define __LIBMEMCACHED_CONSTANTS_H__ | |
| | | | |
| /* Public defines */ | | /* Public defines */ | |
| #define MEMCACHED_DEFAULT_PORT 11211 | | #define MEMCACHED_DEFAULT_PORT 11211 | |
| #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 8196 | | #define MEMCACHED_MAX_BUFFER 8196 | |
|
| #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 | | #define MEMCACHED_EXPIRATION_NOT_ADD 0xffffffffU | |
| #define MEMCACHED_VERSION_STRING_LENGTH 24 | | #define MEMCACHED_VERSION_STRING_LENGTH 24 | |
| | | | |
| skipping to change at line 71 | | skipping to change at line 70 | |
| 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_SERVER_MARKED_DEAD, | |
| MEMCACHED_UNKNOWN_STAT_KEY, | | MEMCACHED_UNKNOWN_STAT_KEY, | |
| MEMCACHED_E2BIG, | | MEMCACHED_E2BIG, | |
| MEMCACHED_INVALID_ARGUMENTS, | | MEMCACHED_INVALID_ARGUMENTS, | |
|
| | | MEMCACHED_KEY_TOO_BIG, | |
| MEMCACHED_MAXIMUM_RETURN /* Always add new error code before */ | | MEMCACHED_MAXIMUM_RETURN /* Always add new error code before */ | |
| } memcached_return_t; | | } memcached_return_t; | |
| | | | |
| 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_DISTRIBUTION_CONSISTENT_KETAMA_SPY, | | MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY, | |
| MEMCACHED_DISTRIBUTION_CONSISTENT_MAX | | MEMCACHED_DISTRIBUTION_CONSISTENT_MAX | |
| | | | |
| skipping to change at line 115 | | skipping to change at line 115 | |
| 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_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_AUTO_EJECT_HOSTS, | |
| MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, | | MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, | |
| MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, | | MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, | |
|
| | | MEMCACHED_BEHAVIOR_CORK, | |
| MEMCACHED_BEHAVIOR_MAX | | MEMCACHED_BEHAVIOR_MAX | |
| } memcached_behavior_t; | | } memcached_behavior_t; | |
| | | | |
| typedef enum { | | typedef enum { | |
| MEMCACHED_CALLBACK_PREFIX_KEY = 0, | | MEMCACHED_CALLBACK_PREFIX_KEY = 0, | |
| MEMCACHED_CALLBACK_USER_DATA = 1, | | MEMCACHED_CALLBACK_USER_DATA = 1, | |
| MEMCACHED_CALLBACK_CLEANUP_FUNCTION = 2, | | MEMCACHED_CALLBACK_CLEANUP_FUNCTION = 2, | |
| MEMCACHED_CALLBACK_CLONE_FUNCTION = 3, | | MEMCACHED_CALLBACK_CLONE_FUNCTION = 3, | |
| #ifdef MEMCACHED_ENABLE_DEPRECATED | | #ifdef MEMCACHED_ENABLE_DEPRECATED | |
| MEMCACHED_CALLBACK_MALLOC_FUNCTION = 4, | | MEMCACHED_CALLBACK_MALLOC_FUNCTION = 4, | |
| | | | |
| skipping to change at line 144 | | skipping to change at line 145 | |
| 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_HSIEH, | | MEMCACHED_HASH_HSIEH, | |
| MEMCACHED_HASH_MURMUR, | | MEMCACHED_HASH_MURMUR, | |
| MEMCACHED_HASH_JENKINS, | | MEMCACHED_HASH_JENKINS, | |
|
| | | MEMCACHED_HASH_CUSTOM, | |
| MEMCACHED_HASH_MAX | | MEMCACHED_HASH_MAX | |
| } memcached_hash_t; | | } memcached_hash_t; | |
| | | | |
| typedef enum { | | typedef enum { | |
| MEMCACHED_CONNECTION_UNKNOWN, | | MEMCACHED_CONNECTION_UNKNOWN, | |
| MEMCACHED_CONNECTION_TCP, | | MEMCACHED_CONNECTION_TCP, | |
| MEMCACHED_CONNECTION_UDP, | | MEMCACHED_CONNECTION_UDP, | |
| MEMCACHED_CONNECTION_UNIX_SOCKET, | | MEMCACHED_CONNECTION_UNIX_SOCKET, | |
| MEMCACHED_CONNECTION_MAX | | MEMCACHED_CONNECTION_MAX | |
| } memcached_connection_t; | | } memcached_connection_t; | |
| | | | |
|
| #endif /* __MEMCACHED_CONSTANTS_H__ */ | | #endif /* __LIBMEMCACHED_CONSTANTS_H__ */ | |
| | | | |
End of changes. 6 change blocks. |
| 3 lines changed or deleted | | 5 lines changed or added | |
|
| hashkit.h | | hashkit.h | |
| /* HashKit | | /* HashKit | |
|
| * Copyright (C) 2009 Brian Aker | | * Copyright (C) 2009-2010 Brian Aker | |
| * All rights reserved. | | * All rights reserved. | |
| * | | * | |
| * Use and distribution licensed under the BSD license. See | | * Use and distribution licensed under the BSD license. See | |
| * the COPYING file in the parent directory for full text. | | * the COPYING file in the parent directory for full text. | |
| */ | | */ | |
| | | | |
|
| /** | | | |
| * @file | | | |
| * @brief HashKit Header | | | |
| */ | | | |
| | | | |
| #ifndef HASHKIT_H | | #ifndef HASHKIT_H | |
| #define HASHKIT_H | | #define HASHKIT_H | |
| | | | |
| #if !defined(__cplusplus) | | #if !defined(__cplusplus) | |
| # include <stdbool.h> | | # include <stdbool.h> | |
| #endif | | #endif | |
| #include <inttypes.h> | | #include <inttypes.h> | |
| #include <sys/types.h> | | #include <sys/types.h> | |
| #include <libhashkit/visibility.h> | | #include <libhashkit/visibility.h> | |
|
| | | #include <libhashkit/configure.h> | |
| #include <libhashkit/types.h> | | #include <libhashkit/types.h> | |
| #include <libhashkit/algorithm.h> | | #include <libhashkit/algorithm.h> | |
| #include <libhashkit/behavior.h> | | #include <libhashkit/behavior.h> | |
|
| | | #include <libhashkit/digest.h> | |
| | | #include <libhashkit/function.h> | |
| #include <libhashkit/strerror.h> | | #include <libhashkit/strerror.h> | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
|
| extern "C" { | | | |
| #endif | | | |
| | | | |
| /** | | | |
| * @addtogroup hashkit_constants Constants | | | |
| * @ingroup hashkit | | | |
| * @{ | | | |
| */ | | | |
| | | | |
| /* Defines. */ | | | |
| #define HASHKIT_MAX_KEY 251 | | | |
| #define HASHKIT_POINTS_PER_NODE 100 | | | |
| #define HASHKIT_POINTS_PER_NODE_WEIGHTED 160 | | | |
| #define HASHKIT_CONTINUUM_ADDITION 10 | | | |
| #define HASHKIT_CONTINUUM_KEY_SIZE 86 | | | |
| | | | |
| /** @} */ | | | |
| | | | |
|
| /** | | #include <string> | |
| * @ingroup hashkit | | | |
| */ | | | |
| struct hashkit_st | | | |
| { | | | |
| hashkit_options_st options; | | | |
| hashkit_distribution_t distribution; | | | |
| uint32_t continuum_count; | | | |
| uint32_t continuum_points_count; | | | |
| size_t list_size; | | | |
| size_t context_size; | | | |
| | | | |
| /** | | | |
| @note There are two places we use hashing, one is for when we have a ke | | | |
| y | | | |
| and we want to find out what server it should be placed on. The second | | | |
| is | | | |
| for when we are placing a value into the continuum. | | | |
| */ | | | |
| hashkit_hash_algorithm_t for_key; | | | |
| hashkit_hash_algorithm_t for_distribution; | | | |
| | | | |
| hashkit_continuum_point_st *continuum; | | | |
| hashkit_fn *hash_fn; | | | |
| hashkit_active_fn *active_fn; | | | |
| hashkit_fn *continuum_hash_fn; | | | |
| hashkit_key_fn *continuum_key_fn; | | | |
| hashkit_sort_fn *sort_fn; | | | |
| hashkit_weight_fn *weight_fn; | | | |
| void *list; | | | |
| }; | | | |
| | | | |
| /** | | | |
| * @ingroup hashkit | | | |
| */ | | | |
| struct hashkit_continuum_point_st | | | |
| { | | | |
| uint32_t index; | | | |
| uint32_t value; | | | |
| }; | | | |
| | | | |
|
| /** | | extern "C" { | |
| * @addtogroup hashkit Pandora Hash Declarations | | #endif | |
| * @{ | | | |
| */ | | | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
| hashkit_st *hashkit_create(hashkit_st *hash); | | hashkit_st *hashkit_create(hashkit_st *hash); | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
| hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *ptr); | | hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *ptr); | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
|
| void hashkit_free(hashkit_st *hash); | | bool hashkit_compare(const hashkit_st *first, const hashkit_st *second); | |
| | | | |
| HASHKIT_API | | HASHKIT_API | |
|
| uint32_t hashkit_generate_value(const char *key, size_t key_length, hashkit
_hash_algorithm_t hash_algorithm); | | void hashkit_free(hashkit_st *hash); | |
| | | | |
| #define hashkit_is_allocated(__object) ((__object)->options.is_allocated) | | #define hashkit_is_allocated(__object) ((__object)->options.is_allocated) | |
| #define hashkit_is_initialized(__object) ((__object)->options.is_initialize
d) | | #define hashkit_is_initialized(__object) ((__object)->options.is_initialize
d) | |
| | | | |
|
| /** @} */ | | #ifdef __cplusplus | |
| | | } // extern "C" | |
| | | #endif | |
| | | | |
| | | struct hashkit_st | |
| | | { | |
| | | struct hashkit_function_st { | |
| | | hashkit_hash_fn function; | |
| | | void *context; | |
| | | } base_hash, distribution_hash; | |
| | | | |
| | | struct { | |
| | | bool is_base_same_distributed HASHKIT_BITFIELD; | |
| | | } flags; | |
| | | | |
| | | struct { | |
| | | bool is_allocated HASHKIT_BITFIELD; | |
| | | } options; | |
| | | }; | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
|
| } | | class Hashkit : private hashkit_st { | |
| | | | |
| | | public: | |
| | | | |
| | | Hashkit() | |
| | | { | |
| | | hashkit_create(this); | |
| | | } | |
| | | | |
| | | Hashkit(const Hashkit& source) | |
| | | { | |
| | | hashkit_clone(this, &source); | |
| | | } | |
| | | | |
| | | Hashkit& operator=(const Hashkit& source) | |
| | | { | |
| | | hashkit_free(this); | |
| | | hashkit_clone(this, &source); | |
| | | | |
| | | return *this; | |
| | | } | |
| | | | |
| | | friend bool operator==(const Hashkit &left, const Hashkit &right) | |
| | | { | |
| | | return hashkit_compare(&left, &right); | |
| | | } | |
| | | | |
| | | uint32_t digest(std::string& str) | |
| | | { | |
| | | return hashkit_digest(this, str.c_str(), str.length()); | |
| | | } | |
| | | | |
| | | uint32_t digest(const char *key, size_t key_length) | |
| | | { | |
| | | return hashkit_digest(this, key, key_length); | |
| | | } | |
| | | | |
| | | hashkit_return_t set_function(hashkit_hash_algorithm_t hash_algorithm) | |
| | | { | |
| | | return hashkit_set_function(this, hash_algorithm); | |
| | | } | |
| | | | |
| | | hashkit_return_t set_distribution_function(hashkit_hash_algorithm_t hash_ | |
| | | algorithm) | |
| | | { | |
| | | return hashkit_set_function(this, hash_algorithm); | |
| | | } | |
| | | | |
| | | ~Hashkit() | |
| | | { | |
| | | hashkit_free(this); | |
| | | } | |
| | | }; | |
| #endif | | #endif | |
| | | | |
| #endif /* HASHKIT_H */ | | #endif /* HASHKIT_H */ | |
| | | | |
End of changes. 11 change blocks. |
| 71 lines changed or deleted | | 81 lines changed or added | |
|
| memcached.h | | memcached.h | |
| | | | |
| skipping to change at line 13 | | skipping to change at line 13 | |
| * All rights reserved. | | * All rights reserved. | |
| * | | * | |
| * Use and distribution licensed under the BSD license. See | | * Use and distribution licensed under the BSD license. See | |
| * the COPYING file in the parent directory for full text. | | * the COPYING file in the parent directory for full text. | |
| * | | * | |
| * Summary: interface for memcached server | | * Summary: interface for memcached server | |
| * Description: main include file for libmemcached | | * Description: main include file for libmemcached | |
| * | | * | |
| */ | | */ | |
| | | | |
|
| #ifndef __MEMCACHED_H__ | | #ifndef __LIBMEMCACHED_MEMCACHED_H__ | |
| #define __MEMCACHED_H__ | | #define __LIBMEMCACHED_MEMCACHED_H__ | |
| | | | |
|
| #include <stdlib.h> | | | |
| #include <inttypes.h> | | #include <inttypes.h> | |
|
| | | #include <netdb.h> | |
| | | #include <netinet/in.h> | |
| | | #include <stdlib.h> | |
| | | #include <sys/types.h> | |
| | | | |
| #if !defined(__cplusplus) | | #if !defined(__cplusplus) | |
| # include <stdbool.h> | | # include <stdbool.h> | |
| #endif | | #endif | |
| | | | |
|
| #include <sys/types.h> | | | |
| #include <netinet/in.h> | | | |
| | | | |
| #include <libmemcached/visibility.h> | | #include <libmemcached/visibility.h> | |
| #include <libmemcached/configure.h> | | #include <libmemcached/configure.h> | |
| #include <libmemcached/constants.h> | | #include <libmemcached/constants.h> | |
| #include <libmemcached/types.h> | | #include <libmemcached/types.h> | |
| #include <libmemcached/string.h> | | #include <libmemcached/string.h> | |
| #include <libmemcached/stats.h> | | #include <libmemcached/stats.h> | |
|
| | | #include <libhashkit/hashkit.h> | |
| // Everything above this line must be in the order specified. | | // Everything above this line must be in the order specified. | |
|
| | | #include <libmemcached/allocators.h> | |
| #include <libmemcached/analyze.h> | | #include <libmemcached/analyze.h> | |
| #include <libmemcached/auto.h> | | #include <libmemcached/auto.h> | |
| #include <libmemcached/behavior.h> | | #include <libmemcached/behavior.h> | |
| #include <libmemcached/callback.h> | | #include <libmemcached/callback.h> | |
|
| | | #include <libmemcached/delete.h> | |
| #include <libmemcached/dump.h> | | #include <libmemcached/dump.h> | |
|
| | | #include <libmemcached/fetch.h> | |
| | | #include <libmemcached/flush.h> | |
| | | #include <libmemcached/flush_buffers.h> | |
| #include <libmemcached/get.h> | | #include <libmemcached/get.h> | |
|
| | | #include <libmemcached/hash.h> | |
| | | #include <libmemcached/parse.h> | |
| | | #include <libmemcached/quit.h> | |
| #include <libmemcached/result.h> | | #include <libmemcached/result.h> | |
| #include <libmemcached/server.h> | | #include <libmemcached/server.h> | |
| #include <libmemcached/storage.h> | | #include <libmemcached/storage.h> | |
|
| | | #include <libmemcached/strerror.h> | |
| #ifdef __cplusplus | | #include <libmemcached/verbosity.h> | |
| extern "C" { | | #include <libmemcached/version.h> | |
| #endif | | | |
| | | | |
| struct memcached_st { | | struct memcached_st { | |
|
| | | /** | |
| | | @note these are static and should not change without a call to behavior | |
| | | . | |
| | | */ | |
| struct { | | struct { | |
|
| bool is_allocated:1; | | bool is_purging MEMCACHED_BITFIELD; | |
| bool is_initialized:1; | | bool is_processing_input MEMCACHED_BITFIELD; | |
| bool is_purging:1; | | } state; | |
| } options; | | struct { | |
| | | // Everything below here is pretty static. | |
| | | bool auto_eject_hosts MEMCACHED_BITFIELD; | |
| | | bool binary_protocol MEMCACHED_BITFIELD; | |
| | | bool buffer_requests MEMCACHED_BITFIELD; | |
| | | bool cork MEMCACHED_BITFIELD; | |
| | | bool hash_with_prefix_key MEMCACHED_BITFIELD; | |
| | | bool ketama_weighted MEMCACHED_BITFIELD; | |
| | | bool no_block MEMCACHED_BITFIELD; | |
| | | bool no_reply MEMCACHED_BITFIELD; | |
| | | bool randomize_replica_read MEMCACHED_BITFIELD; | |
| | | bool reuse_memory MEMCACHED_BITFIELD; | |
| | | bool support_cas MEMCACHED_BITFIELD; | |
| | | bool tcp_nodelay MEMCACHED_BITFIELD; | |
| | | bool use_cache_lookups MEMCACHED_BITFIELD; | |
| | | bool use_sort_hosts MEMCACHED_BITFIELD; | |
| | | bool use_udp MEMCACHED_BITFIELD; | |
| | | bool verify_key MEMCACHED_BITFIELD; | |
| | | } flags; | |
| memcached_server_distribution_t distribution; | | memcached_server_distribution_t distribution; | |
|
| memcached_hash_t hash; | | hashkit_st hashkit; | |
| uint32_t continuum_points_counter; // Ketama | | uint32_t continuum_points_counter; // Ketama | |
|
| memcached_server_st *hosts; | | uint32_t number_of_hosts; | |
| | | memcached_server_st *servers; | |
| memcached_server_st *last_disconnected_server; | | memcached_server_st *last_disconnected_server; | |
| 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; | | uint32_t io_key_prefetch; | |
|
| uint32_t number_of_hosts; | | | |
| int cached_errno; | | int cached_errno; | |
|
| struct { | | | |
| bool auto_eject_hosts:1; | | | |
| bool binary_protocol:1; | | | |
| bool buffer_requests:1; | | | |
| bool hash_with_prefix_key:1; | | | |
| bool ketama_weighted:1; | | | |
| bool no_block:1; | | | |
| bool no_reply:1; | | | |
| bool randomize_replica_read:1; | | | |
| bool reuse_memory:1; | | | |
| bool support_cas:1; | | | |
| bool tcp_nodelay:1; | | | |
| bool use_cache_lookups:1; | | | |
| bool use_sort_hosts:1; | | | |
| bool use_udp:1; | | | |
| bool verify_key:1; | | | |
| } flags; | | | |
| int32_t poll_timeout; | | int32_t poll_timeout; | |
| int32_t connect_timeout; | | int32_t connect_timeout; | |
| int32_t retry_timeout; | | int32_t retry_timeout; | |
| uint32_t continuum_count; // Ketama | | uint32_t continuum_count; // Ketama | |
| int send_size; | | int send_size; | |
| int recv_size; | | int recv_size; | |
| void *user_data; | | void *user_data; | |
| time_t next_distribution_rebuild; // Ketama | | time_t next_distribution_rebuild; // Ketama | |
| size_t prefix_key_length; | | size_t prefix_key_length; | |
| uint32_t number_of_replicas; | | uint32_t number_of_replicas; | |
|
| memcached_hash_t distribution_hash; | | hashkit_st distribution_hashkit; | |
| memcached_result_st result; | | memcached_result_st result; | |
| memcached_continuum_item_st *continuum; // Ketama | | memcached_continuum_item_st *continuum; // Ketama | |
|
| | | | |
| | | struct _allocators_st { | |
| | | memcached_calloc_fn calloc; | |
| | | memcached_free_fn free; | |
| | | memcached_malloc_fn malloc; | |
| | | memcached_realloc_fn realloc; | |
| | | void *context; | |
| | | } allocators; | |
| | | | |
| memcached_clone_fn on_clone; | | memcached_clone_fn on_clone; | |
| memcached_cleanup_fn on_cleanup; | | memcached_cleanup_fn on_cleanup; | |
|
| memcached_free_fn call_free; | | | |
| memcached_malloc_fn call_malloc; | | | |
| memcached_realloc_fn call_realloc; | | | |
| memcached_calloc_fn call_calloc; | | | |
| memcached_trigger_key_fn get_key_failure; | | memcached_trigger_key_fn get_key_failure; | |
| memcached_trigger_delete_key_fn delete_trigger; | | memcached_trigger_delete_key_fn delete_trigger; | |
| memcached_callback_st *callbacks; | | memcached_callback_st *callbacks; | |
| char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE]; | | char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE]; | |
|
| | | struct { | |
| | | bool is_allocated MEMCACHED_BITFIELD; | |
| | | } options; | |
| | | | |
| }; | | }; | |
| | | | |
|
| LIBMEMCACHED_API | | #ifdef __cplusplus | |
| memcached_return_t memcached_version(memcached_st *ptr); | | extern "C" { | |
| | | #endif | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| void memcached_servers_reset(memcached_st *ptr); | | void memcached_servers_reset(memcached_st *ptr); | |
| | | | |
|
| /* Public API */ | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| const char * memcached_lib_version(void); | | | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| memcached_st *memcached_create(memcached_st *ptr); | | memcached_st *memcached_create(memcached_st *ptr); | |
|
| LIBMEMCACHED_API | | | |
| void memcached_free(memcached_st *ptr); | | | |
| LIBMEMCACHED_API | | | |
| memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_delete(memcached_st *ptr, const char *key, siz | | | |
| e_t key_length, | | | |
| time_t expiration); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_verbosity(memcached_st *ptr, unsigned int verb | | | |
| osity); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| void memcached_quit(memcached_st *ptr); | | | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
|
| const char *memcached_strerror(memcached_st *ptr, memcached_return_t rc); | | void memcached_free(memcached_st *ptr); | |
| | | | |
| /* The two public hash bits */ | | | |
| LIBMEMCACHED_API | | | |
| uint32_t memcached_generate_hash_value(const char *key, size_t key_length, | | | |
| memcached_hash_t hash_algorithm); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t | | | |
| key_length); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_flush_buffers(memcached_st *mem); | | | |
| | | | |
| /* Server Public functions */ | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_server_add_udp(memcached_st *ptr, | | | |
| const char *hostname, | | | |
| in_port_t port); | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_server_add_unix_socket(memcached_st *ptr, | | | |
| const char *filename); | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_server_add(memcached_st *ptr, | | | |
| const char *hostname, in_port_t por | | | |
| t); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr, | | | |
| const char *hostnam | | | |
| e, | | | |
| in_port_t port, | | | |
| uint32_t weight); | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_s | | | |
| t *ptr, | | | |
| const char | | | |
| *filename, | | | |
| uint32_t we | | | |
| ight); | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_server_add_with_weight(memcached_st *ptr, cons | | | |
| t char *hostname, | | | |
| in_port_t port, | | | |
| uint32_t weight); | | | |
| LIBMEMCACHED_API | | | |
| void memcached_server_list_free(memcached_server_st *ptr); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_server_push(memcached_st *ptr, memcached_serve | | | |
| r_st *list); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| memcached_server_st *memcached_server_list_append(memcached_server_st *ptr, | | | |
| const char *hostname, | | | |
| in_port_t port, | | | |
| memcached_return_t *error | | | |
| ); | | | |
| LIBMEMCACHED_API | | | |
| memcached_server_st *memcached_server_list_append_with_weight(memcached_ser | | | |
| ver_st *ptr, | | | |
| const char *h | | | |
| ostname, | | | |
| in_port_t por | | | |
| t, | | | |
| uint32_t weig | | | |
| ht, | | | |
| memcached_ret | | | |
| urn_t *error); | | | |
| LIBMEMCACHED_API | | | |
| unsigned int memcached_server_list_count(memcached_server_st *ptr); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| memcached_server_st *memcached_servers_parse(const char *server_strings); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_s | | | |
| tat, | | | |
| const char *key, memcached_return_t *error); | | | |
| LIBMEMCACHED_API | | | |
| char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_ | | | |
| stat, | | | |
| memcached_return_t *error); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_delete_by_key(memcached_st *ptr, | | | |
| const char *master_key, size_t m | | | |
| aster_key_length, | | | |
| const char *key, size_t key_leng | | | |
| th, | | | |
| time_t expiration); | | | |
| | | | |
| LIBMEMCACHED_API | | | |
| memcached_return_t memcached_fetch_execute(memcached_st *ptr, | | | |
| memcached_execute_fn *callback, | | | |
| void *context, | | | |
| unsigned int number_of_callbacks | | | |
| ); | | | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
|
| memcached_return_t memcached_set_memory_allocators(memcached_st *ptr, | | memcached_st *memcached_clone(memcached_st *clone, const memcached_st *ptr) | |
| memcached_malloc_fn mem_ | | ; | |
| malloc, | | | |
| memcached_free_fn mem_fr | | | |
| ee, | | | |
| memcached_realloc_fn mem | | | |
| _realloc, | | | |
| memcached_calloc_fn mem_ | | | |
| calloc); | | | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
|
| void memcached_get_memory_allocators(memcached_st *ptr, | | void *memcached_get_user_data(const memcached_st *ptr); | |
| memcached_malloc_fn *mem_malloc, | | | |
| memcached_free_fn *mem_free, | | | |
| memcached_realloc_fn *mem_realloc, | | | |
| memcached_calloc_fn *mem_calloc); | | | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
|
| void *memcached_get_user_data(memcached_st *ptr); | | | |
| LIBMEMCACHED_API | | | |
| void *memcached_set_user_data(memcached_st *ptr, void *data); | | void *memcached_set_user_data(memcached_st *ptr, void *data); | |
| | | | |
|
| LIBMEMCACHED_LOCAL | | #ifdef __cplusplus | |
| memcached_return_t run_distribution(memcached_st *ptr); | | } // extern "C" | |
| | | #endif | |
| | | | |
|
| #define memcached_is_allocated(__object) ((__object)->options.is_allocated) | | // Local Only Inline | |
| #define memcached_is_initialized(__object) ((__object)->options.is_initiali | | static inline memcached_server_st *memcached_server_instance_fetch(memcache | |
| zed) | | d_st *ptr, uint32_t server_key) | |
| | | { | |
| | | return &ptr->servers[server_key]; | |
| | | } | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
|
| } | | class Memcached : private memcached_st { | |
| | | public: | |
| | | | |
| | | Memcached() | |
| | | { | |
| | | memcached_create(this); | |
| | | } | |
| | | | |
| | | ~Memcached() | |
| | | { | |
| | | memcached_free(this); | |
| | | } | |
| | | | |
| | | Memcached(const Memcached& source) | |
| | | { | |
| | | memcached_clone(this, &source); | |
| | | } | |
| | | | |
| | | Memcached& operator=(const Memcached& source) | |
| | | { | |
| | | memcached_free(this); | |
| | | memcached_clone(this, &source); | |
| | | | |
| | | return *this; | |
| | | } | |
| | | }; | |
| #endif | | #endif | |
| | | | |
|
| #endif /* __MEMCACHED_H__ */ | | #endif /* __LIBMEMCACHED_MEMCACHED_H__ */ | |
| | | | |
End of changes. 31 change blocks. |
| 186 lines changed or deleted | | 103 lines changed or added | |
|
| protocol_handler.h | | protocol_handler.h | |
| | | | |
| skipping to change at line 14 | | skipping to change at line 14 | |
| * | | * | |
| * Use and distribution licensed under the BSD license. See | | * Use and distribution licensed under the BSD license. See | |
| * the COPYING file in the parent directory for full text. | | * the COPYING file in the parent directory for full text. | |
| * | | * | |
| * Summary: Definition of the callback interface to the protocol handler | | * Summary: Definition of the callback interface to the protocol handler | |
| * | | * | |
| * Author: Trond Norbye | | * Author: Trond Norbye | |
| * | | * | |
| */ | | */ | |
| | | | |
|
| #ifndef MEMCACHED_PROTOCOL_H | | #ifndef __LIBMEMCACHED_PROTOCOL_H__ | |
| #define MEMCACHED_PROTOCOL_H | | #define __LIBMEMCACHED_PROTOCOL_H__ | |
| | | | |
| #include <sys/types.h> | | #include <sys/types.h> | |
|
| #include <stdbool.h> | | #if !defined(__cplusplus) | |
| | | # include <stdbool.h> | |
| | | #endif | |
| | | | |
| #include <libmemcached/memcached/protocol_binary.h> | | #include <libmemcached/memcached/protocol_binary.h> | |
| #include <libmemcached/visibility.h> | | #include <libmemcached/visibility.h> | |
| #include <libmemcached/protocol/callback.h> | | #include <libmemcached/protocol/callback.h> | |
| | | | |
| /* Forward declarations */ | | /* Forward declarations */ | |
| /* | | /* | |
| * You should only access memcached_protocol_st from one thread!, | | * You should only access memcached_protocol_st from one thread!, | |
| * and never assume anything about the internal layout / sizes of the | | * and never assume anything about the internal layout / sizes of the | |
| * structures. | | * structures. | |
| */ | | */ | |
| typedef struct memcached_protocol_st memcached_protocol_st; | | typedef struct memcached_protocol_st memcached_protocol_st; | |
| typedef struct memcached_protocol_client_st memcached_protocol_client_st; | | typedef struct memcached_protocol_client_st memcached_protocol_client_st; | |
| | | | |
|
| | | #ifdef __cplusplus | |
| | | extern "C" { | |
| | | #endif | |
| | | | |
| /** | | /** | |
| * Function the protocol handler should call to receive data. | | * Function the protocol handler should call to receive data. | |
| * This function should behave exactly like read(2) | | * This function should behave exactly like read(2) | |
| * | | * | |
| * @param cookie a cookie used to represent a given client | | * @param cookie a cookie used to represent a given client | |
| * @param fd the filedescriptor associated with the client | | * @param fd the filedescriptor associated with the client | |
| * @param buf destination buffer | | * @param buf destination buffer | |
| * @param nbuf number of bytes to receive | | * @param nbuf number of bytes to receive | |
| * @return the number of bytes copied into buf | | * @return the number of bytes copied into buf | |
| * or -1 upon error (errno should contain more information) | | * or -1 upon error (errno should contain more information) | |
| | | | |
| skipping to change at line 205 | | skipping to change at line 211 | |
| int memcached_protocol_client_get_errno(memcached_protocol_client_st *clien
t); | | int memcached_protocol_client_get_errno(memcached_protocol_client_st *clien
t); | |
| | | | |
| /** | | /** | |
| * Get a raw response handler for the given cookie | | * Get a raw response handler for the given cookie | |
| * @param cookie the cookie passed along into the callback | | * @param cookie the cookie passed along into the callback | |
| * @return the raw reponse handler you may use if you find | | * @return the raw reponse handler you may use if you find | |
| * the generic callback too limiting | | * the generic callback too limiting | |
| */ | | */ | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| memcached_binary_protocol_raw_response_handler memcached_binary_protocol_ge
t_raw_response_handler(const void *cookie); | | memcached_binary_protocol_raw_response_handler memcached_binary_protocol_ge
t_raw_response_handler(const void *cookie); | |
|
| | | | |
| | | #ifdef __cplusplus | |
| | | } | |
| | | #endif | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 4 change blocks. |
| 3 lines changed or deleted | | 14 lines changed or added | |
|
| result.h | | result.h | |
| | | | |
| skipping to change at line 12 | | skipping to change at line 12 | |
| * Copyright (C) 2006-2009 Brian Aker | | * Copyright (C) 2006-2009 Brian Aker | |
| * All rights reserved. | | * All rights reserved. | |
| * | | * | |
| * Use and distribution licensed under the BSD license. See | | * Use and distribution licensed under the BSD license. See | |
| * the COPYING file in the parent directory for full text. | | * the COPYING file in the parent directory for full text. | |
| * | | * | |
| * Summary: Functions to manipulate the result structure. | | * Summary: Functions to manipulate the result structure. | |
| * | | * | |
| */ | | */ | |
| | | | |
|
| #ifndef __MEMCACHED_RESULT_H__ | | #ifndef __LIBMEMCACHED_RESULT_H__ | |
| #define __MEMCACHED_RESULT_H__ | | #define __LIBMEMCACHED_RESULT_H__ | |
| | | | |
| #ifdef __cplusplus | | | |
| extern "C" { | | | |
| #endif | | | |
| | | | |
| struct memcached_result_st { | | struct memcached_result_st { | |
|
| struct { | | uint32_t item_flags; | |
| bool is_allocated:1; | | time_t item_expiration; | |
| bool is_initialized:1; | | | |
| } options; | | | |
| uint32_t flags; | | | |
| time_t expiration; | | | |
| memcached_st *root; | | | |
| size_t key_length; | | size_t key_length; | |
|
| uint64_t cas; | | uint64_t item_cas; | |
| | | const memcached_st *root; | |
| memcached_string_st value; | | memcached_string_st value; | |
|
| char key[MEMCACHED_MAX_KEY]; | | char item_key[MEMCACHED_MAX_KEY]; | |
| | | struct { | |
| | | bool is_allocated MEMCACHED_BITFIELD; | |
| | | bool is_initialized MEMCACHED_BITFIELD; | |
| | | } options; | |
| /* Add result callback function */ | | /* Add result callback function */ | |
| }; | | }; | |
| | | | |
|
| | | #ifdef __cplusplus | |
| | | extern "C" { | |
| | | #endif | |
| | | | |
| /* Result Struct */ | | /* Result Struct */ | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| void memcached_result_free(memcached_result_st *result); | | void memcached_result_free(memcached_result_st *result); | |
|
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| void memcached_result_reset(memcached_result_st *ptr); | | void memcached_result_reset(memcached_result_st *ptr); | |
|
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
|
| memcached_result_st *memcached_result_create(memcached_st *ptr, | | memcached_result_st *memcached_result_create(const memcached_st *ptr, | |
| memcached_result_st *result); | | memcached_result_st *result); | |
|
| #define memcached_result_key_value(A) (A)->key | | | |
| #define memcached_result_key_length(A) (A)->key_length | | | |
| #define memcached_result_string_st(A) ((A)->value) | | | |
| #ifdef FIX | | | |
| #define memcached_result_value(A) memcached_string_value((A)->value) | | | |
| #define memcached_result_length(A) memcached_string_length((A)->value) | | | |
| #else | | | |
| | | | |
|
| LIBMEMCACHED_API | | static inline const char *memcached_result_key_value(const memcached_result | |
| char *memcached_result_value(memcached_result_st *ptr); | | _st *self) | |
| | | { | |
| | | return self->key_length ? self->item_key : NULL; | |
| | | } | |
| | | | |
|
| LIBMEMCACHED_API | | static inline size_t memcached_result_key_length(const memcached_result_st | |
| size_t memcached_result_length(memcached_result_st *ptr); | | *self) | |
| | | { | |
| | | return self->key_length; | |
| | | } | |
| | | | |
| | | static inline const char *memcached_result_value(const memcached_result_st | |
| | | *self) | |
| | | { | |
| | | const memcached_string_st *sptr= &self->value; | |
| | | return memcached_string_value(sptr); | |
| | | } | |
| | | | |
| | | static inline size_t memcached_result_length(const memcached_result_st *sel | |
| | | f) | |
| | | { | |
| | | const memcached_string_st *sptr= &self->value; | |
| | | return memcached_string_length(sptr); | |
| | | } | |
| | | | |
| | | static inline uint32_t memcached_result_flags(const memcached_result_st *se | |
| | | lf) | |
| | | { | |
| | | return self->item_flags; | |
| | | } | |
| | | | |
| | | static inline uint64_t memcached_result_cas(const memcached_result_st *self | |
| | | ) | |
| | | { | |
| | | return self->item_cas; | |
| | | } | |
| | | | |
|
| #endif | | | |
| #define memcached_result_flags(A) (A)->flags | | | |
| #define memcached_result_cas(A) (A)->cas | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| memcached_return_t memcached_result_set_value(memcached_result_st *ptr, con
st char *value, size_t length); | | memcached_return_t memcached_result_set_value(memcached_result_st *ptr, con
st char *value, size_t length); | |
|
| #define memcached_result_set_flags(A,B) (A)->flags=(B) | | | |
| #define memcached_result_set_expiration(A,B) (A)->expiration=(B) | | | |
| | | | |
|
| #ifdef __cplusplus | | static inline void memcached_result_set_flags(memcached_result_st *self, ui | |
| | | nt32_t flags) | |
| | | { | |
| | | self->item_flags= flags; | |
| } | | } | |
|
| | | | |
| | | static inline void memcached_result_set_expiration(memcached_result_st *sel | |
| | | f, time_t expiration) | |
| | | { | |
| | | self->item_expiration= expiration; | |
| | | } | |
| | | | |
| | | #ifdef __cplusplus | |
| | | } // extern "C" | |
| #endif | | #endif | |
| | | | |
|
| #endif /* __MEMCACHED_RESULT_H__ */ | | #endif /* __LIBMEMCACHED_RESULT_H__ */ | |
| | | | |
End of changes. 16 change blocks. |
| 33 lines changed or deleted | | 67 lines changed or added | |
|
| server.h | | server.h | |
| | | | |
| skipping to change at line 12 | | skipping to change at line 12 | |
| * Copyright (C) 2006-2009 Brian Aker | | * Copyright (C) 2006-2009 Brian Aker | |
| * All rights reserved. | | * All rights reserved. | |
| * | | * | |
| * Use and distribution licensed under the BSD license. See | | * Use and distribution licensed under the BSD license. See | |
| * the COPYING file in the parent directory for full text. | | * the COPYING file in the parent directory for full text. | |
| * | | * | |
| * Summary: String structure used for libmemcached. | | * Summary: String structure used for libmemcached. | |
| * | | * | |
| */ | | */ | |
| | | | |
|
| #ifndef __MEMCACHED_SERVER_H__ | | #ifndef __LIBMEMCACHED_SERVER_H__ | |
| #define __MEMCACHED_SERVER_H__ | | #define __LIBMEMCACHED_SERVER_H__ | |
| | | | |
| #ifdef __cplusplus | | | |
| extern "C" { | | | |
| #endif | | | |
| | | | |
| struct memcached_server_st { | | struct memcached_server_st { | |
| struct { | | struct { | |
|
| bool is_allocated:1; | | bool is_allocated MEMCACHED_BITFIELD; | |
| bool sockaddr_inited:1; | | bool is_initialized MEMCACHED_BITFIELD; | |
| | | bool sockaddr_inited MEMCACHED_BITFIELD; | |
| | | bool is_shutting_down MEMCACHED_BITFIELD; | |
| } options; | | } options; | |
| uint32_t number_of_hosts; | | uint32_t number_of_hosts; | |
| uint32_t cursor_active; | | uint32_t cursor_active; | |
| in_port_t port; | | in_port_t port; | |
| int cached_errno; | | int cached_errno; | |
| int fd; | | int fd; | |
| uint32_t io_bytes_sent; /* # bytes sent since last read */ | | uint32_t io_bytes_sent; /* # bytes sent since last read */ | |
| uint32_t server_failure_counter; | | uint32_t server_failure_counter; | |
| uint32_t weight; | | uint32_t weight; | |
|
| | | struct { // Place any "state" sort variables in here. | |
| | | bool is_corked; | |
| | | } state; | |
| uint8_t major_version; | | uint8_t major_version; | |
| uint8_t micro_version; | | uint8_t micro_version; | |
| uint8_t minor_version; | | uint8_t minor_version; | |
| memcached_connection_t type; | | memcached_connection_t type; | |
| char *read_ptr; | | char *read_ptr; | |
| char *cached_server_error; | | char *cached_server_error; | |
| size_t read_buffer_length; | | size_t read_buffer_length; | |
| size_t read_data_length; | | size_t read_data_length; | |
| size_t write_buffer_offset; | | size_t write_buffer_offset; | |
| struct addrinfo *address_info; | | struct addrinfo *address_info; | |
| time_t next_retry; | | time_t next_retry; | |
|
| memcached_st *root; | | const memcached_st *root; | |
| uint64_t limit_maxbytes; | | uint64_t limit_maxbytes; | |
| char read_buffer[MEMCACHED_MAX_BUFFER]; | | char read_buffer[MEMCACHED_MAX_BUFFER]; | |
| char write_buffer[MEMCACHED_MAX_BUFFER]; | | char write_buffer[MEMCACHED_MAX_BUFFER]; | |
|
| char hostname[MEMCACHED_MAX_HOST_LENGTH]; | | char hostname[NI_MAXHOST]; | |
| }; | | }; | |
| | | | |
|
| static inline uint32_t memcached_servers_count(memcached_server_st *servers | | #ifdef __cplusplus | |
| ) | | extern "C" { | |
| { | | #endif | |
| return servers->number_of_hosts; | | | |
| } | | | |
| | | | |
| static inline uint32_t memcached_servers_set_count(memcached_server_st *ser | | | |
| vers, uint32_t count) | | | |
| { | | | |
| return servers->number_of_hosts= count; | | | |
| } | | | |
| | | | |
| #define memcached_server_count(A) (A)->number_of_hosts | | | |
| #define memcached_server_name(A,B) (B).hostname | | | |
| #define memcached_server_port(A,B) (B).port | | | |
| #define memcached_server_list(A) (A)->hosts | | | |
| #define memcached_server_response_count(A) (A)->cursor_active | | | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| memcached_return_t memcached_server_cursor(memcached_st *ptr, | | memcached_return_t memcached_server_cursor(memcached_st *ptr, | |
| memcached_server_fn *callback, | | memcached_server_fn *callback, | |
| void *context, | | void *context, | |
| uint32_t number_of_callbacks); | | uint32_t number_of_callbacks); | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| memcached_server_st *memcached_server_by_key(memcached_st *ptr, | | memcached_server_st *memcached_server_by_key(memcached_st *ptr, | |
| const char *key, | | const char *key, | |
| | | | |
| skipping to change at line 87 | | skipping to change at line 76 | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| const char *memcached_server_error(memcached_server_st *ptr); | | const char *memcached_server_error(memcached_server_st *ptr); | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| void memcached_server_error_reset(memcached_server_st *ptr); | | void memcached_server_error_reset(memcached_server_st *ptr); | |
| | | | |
| /* These should not currently be used by end users */ | | /* These should not currently be used by end users */ | |
| /* TODO: Is the above comment valid? If so, how can we unit test these if t
hey | | /* TODO: Is the above comment valid? If so, how can we unit test these if t
hey | |
| * aren't exported. If not, we should remove the comment */ | | * aren't exported. If not, we should remove the comment */ | |
|
| LIBMEMCACHED_API | | | |
| memcached_server_st *memcached_server_create(memcached_st *memc, memcached_ | | | |
| server_st *ptr); | | | |
| | | | |
|
| LIBMEMCACHED_API | | LIBMEMCACHED_LOCAL | |
| memcached_server_st *memcached_server_create_with(memcached_st *memc, | | memcached_server_st *memcached_server_create_with(const memcached_st *memc, | |
| memcached_server_st *host
, | | memcached_server_st *host
, | |
| const char *hostname, | | const char *hostname, | |
| in_port_t port, | | in_port_t port, | |
| uint32_t weight, | | uint32_t weight, | |
| memcached_connection_t ty
pe); | | memcached_connection_t ty
pe); | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| void memcached_server_free(memcached_server_st *ptr); | | void memcached_server_free(memcached_server_st *ptr); | |
| | | | |
|
| LIBMEMCACHED_API | | LIBMEMCACHED_LOCAL | |
| memcached_server_st *memcached_server_clone(memcached_server_st *clone, | | memcached_server_st *memcached_server_clone(memcached_server_st *destinatio | |
| memcached_server_st *ptr); | | n, | |
| | | const memcached_server_st *sour | |
| | | ce); | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| memcached_return_t memcached_server_remove(memcached_server_st *st_ptr); | | memcached_return_t memcached_server_remove(memcached_server_st *st_ptr); | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| memcached_server_st *memcached_server_get_last_disconnect(memcached_st *ptr
); | | memcached_server_st *memcached_server_get_last_disconnect(memcached_st *ptr
); | |
| | | | |
|
| #ifdef __cplusplus | | LIBMEMCACHED_API | |
| | | memcached_return_t memcached_server_add_udp(memcached_st *ptr, | |
| | | const char *hostname, | |
| | | in_port_t port); | |
| | | LIBMEMCACHED_API | |
| | | memcached_return_t memcached_server_add_unix_socket(memcached_st *ptr, | |
| | | const char *filename); | |
| | | LIBMEMCACHED_API | |
| | | memcached_return_t memcached_server_add(memcached_st *ptr, | |
| | | const char *hostname, in_port_t por | |
| | | t); | |
| | | | |
| | | LIBMEMCACHED_API | |
| | | memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr, | |
| | | const char *hostnam | |
| | | e, | |
| | | in_port_t port, | |
| | | uint32_t weight); | |
| | | LIBMEMCACHED_API | |
| | | memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_s | |
| | | t *ptr, | |
| | | const char | |
| | | *filename, | |
| | | uint32_t we | |
| | | ight); | |
| | | LIBMEMCACHED_API | |
| | | memcached_return_t memcached_server_add_with_weight(memcached_st *ptr, cons | |
| | | t char *hostname, | |
| | | in_port_t port, | |
| | | uint32_t weight); | |
| | | /* Server List Public functions */ | |
| | | | |
| | | LIBMEMCACHED_API | |
| | | void memcached_server_list_free(memcached_server_st *ptr); | |
| | | | |
| | | LIBMEMCACHED_API | |
| | | memcached_return_t memcached_server_push(memcached_st *ptr, memcached_serve | |
| | | r_st *list); | |
| | | | |
| | | LIBMEMCACHED_API | |
| | | memcached_server_st *memcached_server_list_append(memcached_server_st *ptr, | |
| | | const char *hostname, | |
| | | in_port_t port, | |
| | | memcached_return_t *error | |
| | | ); | |
| | | LIBMEMCACHED_API | |
| | | memcached_server_st *memcached_server_list_append_with_weight(memcached_ser | |
| | | ver_st *ptr, | |
| | | const char *h | |
| | | ostname, | |
| | | in_port_t por | |
| | | t, | |
| | | uint32_t weig | |
| | | ht, | |
| | | memcached_ret | |
| | | urn_t *error); | |
| | | LIBMEMCACHED_API | |
| | | unsigned int memcached_server_list_count(memcached_server_st *ptr); | |
| | | | |
| | | // Local Only Inline | |
| | | static inline uint32_t memcached_servers_count(memcached_server_st *servers | |
| | | ) | |
| | | { | |
| | | return servers->number_of_hosts; | |
| | | } | |
| | | | |
| | | // Local Only Inline | |
| | | static inline uint32_t memcached_servers_set_count(memcached_server_st *ser | |
| | | vers, uint32_t count) | |
| | | { | |
| | | return servers->number_of_hosts= count; | |
| } | | } | |
|
| | | | |
| | | #define memcached_server_count(A) (A)->number_of_hosts | |
| | | #define memcached_server_name(A,B) (B).hostname | |
| | | #define memcached_server_port(A,B) (B).port | |
| | | #define memcached_server_list(A) (A)->servers | |
| | | #define memcached_server_list_set(A,B) (A)->servers=(B) | |
| | | #define memcached_server_response_count(A) (A)->cursor_active | |
| | | | |
| | | #ifdef __cplusplus | |
| | | } // extern "C" | |
| #endif | | #endif | |
| | | | |
|
| #endif /* __MEMCACHED_SERVER_H__ */ | | #endif /* __LIBMEMCACHED_SERVER_H__ */ | |
| | | | |
End of changes. 12 change blocks. |
| 36 lines changed or deleted | | 102 lines changed or added | |
|
| stats.h | | stats.h | |
| | | | |
| skipping to change at line 12 | | skipping to change at line 12 | |
| * Copyright (C) 2006-2009 Brian Aker | | * Copyright (C) 2006-2009 Brian Aker | |
| * All rights reserved. | | * All rights reserved. | |
| * | | * | |
| * Use and distribution licensed under the BSD license. See | | * Use and distribution licensed under the BSD license. See | |
| * the COPYING file in the parent directory for full text. | | * the COPYING file in the parent directory for full text. | |
| * | | * | |
| * Summary: Collect up the stats for a memcached server. | | * Summary: Collect up the stats for a memcached server. | |
| * | | * | |
| */ | | */ | |
| | | | |
|
| #ifndef __MEMCACHED_STATS_H__ | | #ifndef __LIBMEMCACHED_STATS_H__ | |
| #define __MEMCACHED_STATS_H__ | | #define __LIBMEMCACHED_STATS_H__ | |
| | | | |
| #ifdef __cplusplus | | | |
| extern "C" { | | | |
| #endif | | | |
| | | | |
| struct memcached_stat_st { | | struct memcached_stat_st { | |
| uint32_t connection_structures; | | uint32_t connection_structures; | |
| uint32_t curr_connections; | | uint32_t curr_connections; | |
| uint32_t curr_items; | | uint32_t curr_items; | |
| uint32_t pid; | | uint32_t pid; | |
| uint32_t pointer_size; | | uint32_t pointer_size; | |
| uint32_t rusage_system_microseconds; | | uint32_t rusage_system_microseconds; | |
| uint32_t rusage_system_seconds; | | uint32_t rusage_system_seconds; | |
| uint32_t rusage_user_microseconds; | | uint32_t rusage_user_microseconds; | |
| | | | |
| skipping to change at line 47 | | skipping to change at line 43 | |
| uint64_t cmd_get; | | uint64_t cmd_get; | |
| uint64_t cmd_set; | | uint64_t cmd_set; | |
| uint64_t evictions; | | uint64_t evictions; | |
| uint64_t get_hits; | | uint64_t get_hits; | |
| uint64_t get_misses; | | uint64_t get_misses; | |
| uint64_t limit_maxbytes; | | uint64_t limit_maxbytes; | |
| char version[MEMCACHED_VERSION_STRING_LENGTH]; | | char version[MEMCACHED_VERSION_STRING_LENGTH]; | |
| memcached_st *root; | | memcached_st *root; | |
| }; | | }; | |
| | | | |
|
| | | #ifdef __cplusplus | |
| | | extern "C" { | |
| | | #endif | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| void memcached_stat_free(memcached_st *, memcached_stat_st *); | | void memcached_stat_free(memcached_st *, memcached_stat_st *); | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_
return_t *error); | | memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_
return_t *error); | |
| | | | |
| LIBMEMCACHED_API | | LIBMEMCACHED_API | |
| memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat,
char *args, | | memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat,
char *args, | |
| const char *hostname, in_port_
t port); | | const char *hostname, in_port_
t port); | |
| | | | |
|
| | | LIBMEMCACHED_API | |
| | | char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_s | |
| | | tat, | |
| | | const char *key, memcached_return_t *error); | |
| | | | |
| | | LIBMEMCACHED_API | |
| | | char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_ | |
| | | stat, | |
| | | memcached_return_t *error); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
|
| } | | } // extern "C" | |
| #endif | | #endif | |
| | | | |
|
| #endif /* __MEMCACHED_STATS_H__ */ | | #endif /* __LIBMEMCACHED_STATS_H__ */ | |
| | | | |
End of changes. 5 change blocks. |
| 7 lines changed or deleted | | 17 lines changed or added | |
|
| string.h | | string.h | |
| | | | |
| skipping to change at line 12 | | skipping to change at line 12 | |
| * Copyright (C) 2006-2009 Brian Aker | | * Copyright (C) 2006-2009 Brian Aker | |
| * All rights reserved. | | * All rights reserved. | |
| * | | * | |
| * Use and distribution licensed under the BSD license. See | | * Use and distribution licensed under the BSD license. See | |
| * the COPYING file in the parent directory for full text. | | * the COPYING file in the parent directory for full text. | |
| * | | * | |
| * Summary: String structure used for libmemcached. | | * Summary: String structure used for libmemcached. | |
| * | | * | |
| */ | | */ | |
| | | | |
|
| #ifndef __MEMCACHED_STRING_H__ | | #ifndef __LIBMEMCACHED_STRING_H__ | |
| #define __MEMCACHED_STRING_H__ | | #define __LIBMEMCACHED_STRING_H__ | |
| | | | |
|
| #ifdef __cplusplus | | /** | |
| extern "C" { | | Strings are always under our control so we make some assumptions | |
| #endif | | about them. | |
| | | | |
| | | 1) is_initialized is always valid. | |
| | | 2) A string once intialized will always be, until free where we | |
| | | unset this flag. | |
| | | 3) A string always has a root. | |
| | | */ | |
| | | | |
| struct memcached_string_st { | | struct memcached_string_st { | |
|
| memcached_st *root; | | | |
| char *end; | | char *end; | |
| char *string; | | char *string; | |
| size_t current_size; | | size_t current_size; | |
|
| size_t block_size; | | const memcached_st *root; | |
| struct { | | struct { | |
|
| bool is_allocated:1; | | bool is_allocated MEMCACHED_BITFIELD; | |
| bool is_initialized:1; | | bool is_initialized MEMCACHED_BITFIELD; | |
| } options; | | } options; | |
| }; | | }; | |
| | | | |
|
| #define memcached_string_length(A) (size_t)((A)->end - (A)->string) | | #ifdef __cplusplus | |
| #define memcached_string_set_length(A, B) (A)->end= (A)->string + B | | extern "C" { | |
| #define memcached_string_size(A) (A)->current_size | | #endif | |
| #define memcached_string_value(A) (A)->string | | | |
| | | | |
| LIBMEMCACHED_LOCAL | | LIBMEMCACHED_LOCAL | |
|
| memcached_string_st *memcached_string_create(memcached_st *ptr, | | memcached_string_st *memcached_string_create(const memcached_st *ptr, | |
| memcached_string_st *string, | | memcached_string_st *string, | |
| size_t initial_size); | | size_t initial_size); | |
| LIBMEMCACHED_LOCAL | | LIBMEMCACHED_LOCAL | |
| memcached_return_t memcached_string_check(memcached_string_st *string, size
_t need); | | memcached_return_t memcached_string_check(memcached_string_st *string, size
_t need); | |
| | | | |
| LIBMEMCACHED_LOCAL | | LIBMEMCACHED_LOCAL | |
| char *memcached_string_c_copy(memcached_string_st *string); | | char *memcached_string_c_copy(memcached_string_st *string); | |
| | | | |
| LIBMEMCACHED_LOCAL | | LIBMEMCACHED_LOCAL | |
| memcached_return_t memcached_string_append_character(memcached_string_st *s
tring, | | memcached_return_t memcached_string_append_character(memcached_string_st *s
tring, | |
| char character); | | char character); | |
| LIBMEMCACHED_LOCAL | | LIBMEMCACHED_LOCAL | |
| memcached_return_t memcached_string_append(memcached_string_st *string, | | memcached_return_t memcached_string_append(memcached_string_st *string, | |
| const char *value, size_t length
); | | const char *value, size_t length
); | |
| LIBMEMCACHED_LOCAL | | LIBMEMCACHED_LOCAL | |
| memcached_return_t memcached_string_reset(memcached_string_st *string); | | memcached_return_t memcached_string_reset(memcached_string_st *string); | |
| | | | |
| LIBMEMCACHED_LOCAL | | LIBMEMCACHED_LOCAL | |
| void memcached_string_free(memcached_string_st *string); | | void memcached_string_free(memcached_string_st *string); | |
| | | | |
|
| | | static inline size_t memcached_string_length(const memcached_string_st *sel | |
| | | f) | |
| | | { | |
| | | return (size_t)(self->end - self->string); | |
| | | } | |
| | | | |
| | | static inline size_t memcached_string_size(const memcached_string_st *self) | |
| | | { | |
| | | return self->current_size; | |
| | | } | |
| | | | |
| | | static inline const char *memcached_string_value(const memcached_string_st | |
| | | *self) | |
| | | { | |
| | | return self->string; | |
| | | } | |
| | | | |
| | | static inline char *memcached_string_value_mutable(const memcached_string_s | |
| | | t *self) | |
| | | { | |
| | | return self->string; | |
| | | } | |
| | | | |
| | | #define memcached_string_set_length(A, B) (A)->end= (A)->string + B | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
|
| #endif /* __MEMCACHED_STRING_H__ */ | | #endif /* __LIBMEMCACHED_STRING_H__ */ | |
| | | | |
End of changes. 9 change blocks. |
| 14 lines changed or deleted | | 43 lines changed or added | |
|
| types.h | | types.h | |
| | | | |
| /* HashKit | | /* HashKit | |
| * Copyright (C) 2009 Brian Aker | | * Copyright (C) 2009 Brian Aker | |
| * All rights reserved. | | * All rights reserved. | |
| * | | * | |
| * Use and distribution licensed under the BSD license. See | | * Use and distribution licensed under the BSD license. See | |
| * the COPYING file in the parent directory for full text. | | * the COPYING file in the parent directory for full text. | |
| */ | | */ | |
| | | | |
|
| /** | | | |
| * @file | | | |
| * @brief HashKit Header | | | |
| */ | | | |
| | | | |
| #ifndef HASHKIT_TYPES_H | | #ifndef HASHKIT_TYPES_H | |
| #define HASHKIT_TYPES_H | | #define HASHKIT_TYPES_H | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
|
| | | | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| /** | | | |
| * @addtogroup hashkit_types Types | | | |
| * @ingroup hashkit | | | |
| * @{ | | | |
| */ | | | |
| | | | |
| typedef enum { | | typedef enum { | |
| HASHKIT_SUCCESS, | | HASHKIT_SUCCESS, | |
| HASHKIT_FAILURE, | | HASHKIT_FAILURE, | |
| HASHKIT_MEMORY_ALLOCATION_FAILURE, | | HASHKIT_MEMORY_ALLOCATION_FAILURE, | |
| HASHKIT_MAXIMUM_RETURN /* Always add new error code before */ | | HASHKIT_MAXIMUM_RETURN /* Always add new error code before */ | |
| } hashkit_return_t; | | } hashkit_return_t; | |
| | | | |
|
| /** | | | |
| @todo hashkit_options_t is for future use, currently we do not define any | | | |
| user options. | | | |
| */ | | | |
| | | | |
| typedef enum | | | |
| { | | | |
| HASHKIT_OPTION_MAX | | | |
| } hashkit_options_t; | | | |
| | | | |
| typedef struct | | | |
| { | | | |
| /* We use the following for internal book keeping. */ | | | |
| bool is_initialized:1; | | | |
| bool is_allocated:1; | | | |
| } hashkit_options_st; | | | |
| | | | |
| typedef enum { | | typedef enum { | |
|
| HASHKIT_HASH_DEFAULT= 0, | | HASHKIT_HASH_DEFAULT= 0, // hashkit_one_at_a_time() | |
| HASHKIT_HASH_MD5, | | HASHKIT_HASH_MD5, | |
| HASHKIT_HASH_CRC, | | HASHKIT_HASH_CRC, | |
| HASHKIT_HASH_FNV1_64, | | HASHKIT_HASH_FNV1_64, | |
| HASHKIT_HASH_FNV1A_64, | | HASHKIT_HASH_FNV1A_64, | |
| HASHKIT_HASH_FNV1_32, | | HASHKIT_HASH_FNV1_32, | |
| HASHKIT_HASH_FNV1A_32, | | HASHKIT_HASH_FNV1A_32, | |
| HASHKIT_HASH_HSIEH, | | HASHKIT_HASH_HSIEH, | |
| HASHKIT_HASH_MURMUR, | | HASHKIT_HASH_MURMUR, | |
| HASHKIT_HASH_JENKINS, | | HASHKIT_HASH_JENKINS, | |
|
| | | HASHKIT_HASH_CUSTOM, | |
| HASHKIT_HASH_MAX | | HASHKIT_HASH_MAX | |
| } hashkit_hash_algorithm_t; | | } hashkit_hash_algorithm_t; | |
| | | | |
| /** | | /** | |
| * Hash distributions that are available to use. | | * Hash distributions that are available to use. | |
| */ | | */ | |
| typedef enum | | typedef enum | |
| { | | { | |
| HASHKIT_DISTRIBUTION_MODULA, | | HASHKIT_DISTRIBUTION_MODULA, | |
| HASHKIT_DISTRIBUTION_RANDOM, | | HASHKIT_DISTRIBUTION_RANDOM, | |
| HASHKIT_DISTRIBUTION_KETAMA, | | HASHKIT_DISTRIBUTION_KETAMA, | |
| HASHKIT_DISTRIBUTION_MAX /* Always add new values before this. */ | | HASHKIT_DISTRIBUTION_MAX /* Always add new values before this. */ | |
| } hashkit_distribution_t; | | } hashkit_distribution_t; | |
| | | | |
| typedef struct hashkit_st hashkit_st; | | typedef struct hashkit_st hashkit_st; | |
|
| typedef struct hashkit_continuum_point_st hashkit_continuum_point_st; | | | |
| typedef bool (hashkit_active_fn)(void *context); | | | |
| typedef uint32_t (hashkit_fn)(const char *key, size_t key_length); | | | |
| typedef size_t (hashkit_key_fn)(char *key, size_t key_length, uint32_t poin | | | |
| t_index, void *context); | | | |
| typedef void (hashkit_sort_fn)(void *context, size_t count); | | | |
| typedef uint32_t (hashkit_weight_fn)(void *context); | | | |
| | | | |
|
| /** @} */ | | typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length, voi
d *context); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif /* HASHKIT_TYPES_H */ | | #endif /* HASHKIT_TYPES_H */ | |
| | | | |
End of changes. 8 change blocks. |
| 37 lines changed or deleted | | 4 lines changed or added | |
|
| watchpoint.h | | watchpoint.h | |
| | | | |
| skipping to change at line 12 | | skipping to change at line 12 | |
| * Copyright (C) 2006-2009 Brian Aker | | * Copyright (C) 2006-2009 Brian Aker | |
| * All rights reserved. | | * All rights reserved. | |
| * | | * | |
| * Use and distribution licensed under the BSD license. See | | * Use and distribution licensed under the BSD license. See | |
| * the COPYING file in the parent directory for full text. | | * the COPYING file in the parent directory for full text. | |
| * | | * | |
| * Summary: Localized copy of WATCHPOINT debug symbols | | * Summary: Localized copy of WATCHPOINT debug symbols | |
| * | | * | |
| */ | | */ | |
| | | | |
|
| #ifndef LIBMEMCACHED_MEMCACHED_WATCHPOINT_H | | #ifndef __LIBMEMCACHED_WATCHPOINT_H__ | |
| #define LIBMEMCACHED_MEMCACHED_WATCHPOINT_H | | #define __LIBMEMCACHED_WATCHPOINT_H__ | |
| | | | |
| /* Some personal debugging functions */ | | /* Some personal debugging functions */ | |
| #if defined(DEBUG) | | #if defined(DEBUG) | |
| | | | |
|
| | | #ifdef TARGET_OS_LINUX | |
| | | static inline void __stack_dump(void) | |
| | | { | |
| | | void *array[10]; | |
| | | int size; | |
| | | char **strings; | |
| | | | |
| | | size= backtrace(array, 10); | |
| | | strings= backtrace_symbols(array, size); | |
| | | | |
| | | fprintf(stderr, "Found %d stack frames.\n", size); | |
| | | | |
| | | for (int x= 0; x < size; x++) | |
| | | fprintf(stderr, "%s\n", strings[x]); | |
| | | | |
| | | free (strings); | |
| | | | |
| | | fflush(stderr); | |
| | | } | |
| | | | |
| | | #else | |
| | | | |
| | | static inline void __stack_dump(void) | |
| | | { } | |
| | | | |
| | | #endif // __stack_dump() | |
| | | | |
| #include <assert.h> | | #include <assert.h> | |
| | | | |
| #define WATCHPOINT do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s)\n", __FILE
__, __LINE__,__func__);fflush(stdout); } while (0) | | #define WATCHPOINT do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s)\n", __FILE
__, __LINE__,__func__);fflush(stdout); } while (0) | |
| #define WATCHPOINT_ERROR(A) do {fprintf(stderr, "\nWATCHPOINT %s:%d %s\n",
__FILE__, __LINE__, memcached_strerror(NULL, A));fflush(stdout); } while (0
) | | #define WATCHPOINT_ERROR(A) do {fprintf(stderr, "\nWATCHPOINT %s:%d %s\n",
__FILE__, __LINE__, memcached_strerror(NULL, A));fflush(stdout); } while (0
) | |
| #define WATCHPOINT_IFERROR(A) do { if(A != MEMCACHED_SUCCESS)fprintf(stderr
, "\nWATCHPOINT %s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, A
));fflush(stdout); } while (0) | | #define WATCHPOINT_IFERROR(A) do { if(A != MEMCACHED_SUCCESS)fprintf(stderr
, "\nWATCHPOINT %s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, A
));fflush(stdout); } while (0) | |
| #define WATCHPOINT_STRING(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s)
%s\n", __FILE__, __LINE__,__func__,A);fflush(stdout); } while (0) | | #define WATCHPOINT_STRING(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s)
%s\n", __FILE__, __LINE__,__func__,A);fflush(stdout); } while (0) | |
| #define WATCHPOINT_STRING_LENGTH(A,B) do { fprintf(stderr, "\nWATCHPOINT %s
:%d (%s) %.*s\n", __FILE__, __LINE__,__func__,(int)B,A);fflush(stdout); } w
hile (0) | | #define WATCHPOINT_STRING_LENGTH(A,B) do { fprintf(stderr, "\nWATCHPOINT %s
:%d (%s) %.*s\n", __FILE__, __LINE__,__func__,(int)B,A);fflush(stdout); } w
hile (0) | |
| #define WATCHPOINT_NUMBER(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s)
%zu\n", __FILE__, __LINE__,__func__,(size_t)(A));fflush(stdout); } while (0
) | | #define WATCHPOINT_NUMBER(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s)
%zu\n", __FILE__, __LINE__,__func__,(size_t)(A));fflush(stdout); } while (0
) | |
| #define WATCHPOINT_ERRNO(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %
s\n", __FILE__, __LINE__,__func__, strerror(A));fflush(stdout); } while (0) | | #define WATCHPOINT_ERRNO(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %
s\n", __FILE__, __LINE__,__func__, strerror(A));fflush(stdout); } while (0) | |
|
| #define WATCHPOINT_ASSERT_PRINT(A,B,C) do { if(!(A)){fprintf(stderr, "\nWAT | | #define WATCHPOINT_ASSERT_PRINT(A,B,C) do { if(!(A)){fprintf(stderr, "\nWAT | |
| CHPOINT ASSERT %s:%d (%s) ", __FILE__, __LINE__,__func__);fprintf(stderr, ( | | CHPOINT ASSERT %s:%d (%s) ", __FILE__, __LINE__,__func__);fprintf(stderr, ( | |
| B),(C));fprintf(stderr,"\n");fflush(stdout);}assert((A)); } while (0) | | B),(C));fprintf(stderr,"\n");fflush(stdout); __stack_dump(); } assert((A)); | |
| #define WATCHPOINT_ASSERT(A) assert((A)) | | } while (0) | |
| #define WATCHPOINT_ASSERT_INITIALIZED(A) assert(memcached_is_initialized((A | | #define WATCHPOINT_ASSERT(A) do { if (! (A)) {__stack_dump();} assert((A)); | |
| ))) | | } while (0) | |
| | | #define WATCHPOINT_ASSERT_INITIALIZED(A) do { if (! (A)) { __stack_dump(); | |
| | | } assert(memcached_is_initialized((A))); } while (0); | |
| | | #define WATCHPOINT_SET(A) do { A; } while(0); | |
| | | | |
| #else | | #else | |
| | | | |
| #define WATCHPOINT | | #define WATCHPOINT | |
| #define WATCHPOINT_ERROR(A) | | #define WATCHPOINT_ERROR(A) | |
| #define WATCHPOINT_IFERROR(A) | | #define WATCHPOINT_IFERROR(A) | |
| #define WATCHPOINT_STRING(A) | | #define WATCHPOINT_STRING(A) | |
| #define WATCHPOINT_NUMBER(A) | | #define WATCHPOINT_NUMBER(A) | |
| #define WATCHPOINT_ERRNO(A) | | #define WATCHPOINT_ERRNO(A) | |
| #define WATCHPOINT_ASSERT_PRINT(A,B,C) | | #define WATCHPOINT_ASSERT_PRINT(A,B,C) | |
| #define WATCHPOINT_ASSERT(A) | | #define WATCHPOINT_ASSERT(A) | |
| #define WATCHPOINT_ASSERT_INITIALIZED(A) | | #define WATCHPOINT_ASSERT_INITIALIZED(A) | |
|
| | | #define WATCHPOINT_SET(A) | |
| | | | |
| #endif /* DEBUG */ | | #endif /* DEBUG */ | |
| | | | |
|
| #endif /* LIBMEMCACHED_MEMCACHED_WATCHPOINT_H */ | | #endif /* __LIBMEMCACHED_WATCHPOINT_H__ */ | |
| | | | |
End of changes. 5 change blocks. |
| 8 lines changed or deleted | | 39 lines changed or added | |
|