Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cellframe/cellframe-node
  • evseev/cellframe-node
  • dmitry.puzyrkov/cellframe-node
  • MIKA83/cellframe-node
4 results
Show changes
Showing
with 0 additions and 1317 deletions
/* HashKit
* Copyright (C) 2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*/
#ifndef HASHKIT_TYPES_H
#define HASHKIT_TYPES_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
HASHKIT_SUCCESS,
HASHKIT_FAILURE,
HASHKIT_MEMORY_ALLOCATION_FAILURE,
HASHKIT_MAXIMUM_RETURN /* Always add new error code before */
} hashkit_return_t;
typedef enum {
HASHKIT_HASH_DEFAULT= 0, // hashkit_one_at_a_time()
HASHKIT_HASH_MD5,
HASHKIT_HASH_CRC,
HASHKIT_HASH_FNV1_64,
HASHKIT_HASH_FNV1A_64,
HASHKIT_HASH_FNV1_32,
HASHKIT_HASH_FNV1A_32,
HASHKIT_HASH_HSIEH,
HASHKIT_HASH_MURMUR,
HASHKIT_HASH_JENKINS,
HASHKIT_HASH_CUSTOM,
HASHKIT_HASH_MAX
} hashkit_hash_algorithm_t;
/**
* Hash distributions that are available to use.
*/
typedef enum
{
HASHKIT_DISTRIBUTION_MODULA,
HASHKIT_DISTRIBUTION_RANDOM,
HASHKIT_DISTRIBUTION_KETAMA,
HASHKIT_DISTRIBUTION_MAX /* Always add new values before this. */
} hashkit_distribution_t;
typedef struct hashkit_st hashkit_st;
typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length, void *context);
#ifdef __cplusplus
}
#endif
#endif /* HASHKIT_TYPES_H */
/*
* Summary: interface for HashKit functions
* Description: visibitliy macros for HashKit library
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in this directory for full text.
*
* Author: Monty Taylor
*/
/**
* @file
* @brief Visibility control macros
*/
#ifndef HASHKIT_VISIBILITY_H
#define HASHKIT_VISIBILITY_H
/**
*
* HASHKIT_API is used for the public API symbols. It either DLL imports or
* DLL exports (or does nothing for static build).
*
* HASHKIT_LOCAL is used for non-api symbols.
*/
#if defined(BUILDING_HASHKIT)
# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
# define HASHKIT_API __attribute__ ((visibility("default")))
# define HASHKIT_LOCAL __attribute__ ((visibility("hidden")))
# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
# define HASHKIT_API __global
# define HASHKIT_LOCAL __hidden
# elif defined(_MSC_VER)
# define HASHKIT_API extern __declspec(dllexport)
# define HASHKIT_LOCAL
# else
# define HASHKIT_API
# define HASHKIT_LOCAL
# endif /* defined(HAVE_VISIBILITY) */
#else /* defined(BUILDING_HASHKIT) */
# if defined(_MSC_VER)
# define HASHKIT_API extern __declspec(dllimport)
# define HASHKIT_LOCAL
# else
# define HASHKIT_API
# define HASHKIT_LOCAL
# endif /* defined(_MSC_VER) */
#endif /* defined(BUILDING_HASHKIT) */
#endif /* HASHKIT_VISIBILITY_H */
/* LibMemcached
* Copyright (C) 2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: work with user defined memory allocators
*
*/
#ifndef __LIBMEMCACHED_ALLOCATORS_H__
#define __LIBMEMCACHED_ALLOCATORS_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_return_t memcached_set_memory_allocators(memcached_st *ptr,
memcached_malloc_fn mem_malloc,
memcached_free_fn mem_free,
memcached_realloc_fn mem_realloc,
memcached_calloc_fn mem_calloc,
void *context);
LIBMEMCACHED_API
void memcached_get_memory_allocators(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
void *memcached_get_memory_allocators_context(const memcached_st *ptr);
LIBMEMCACHED_LOCAL
void _libmemcached_free(const memcached_st *ptr, void *mem, void *context);
LIBMEMCACHED_LOCAL
void *_libmemcached_malloc(const memcached_st *ptr, const size_t size, void *context);
LIBMEMCACHED_LOCAL
void *_libmemcached_realloc(const memcached_st *ptr, void *mem, const size_t size, void *context);
LIBMEMCACHED_LOCAL
void *_libmemcached_calloc(const memcached_st *ptr, size_t nelem, size_t size, void *context);
LIBMEMCACHED_LOCAL
struct _allocators_st memcached_allocators_return_default(void);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_ALLOCATORS_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Generate a memcached_analysis_st
*
*/
#ifndef __LIBMEMCACHED_ANALYZE_H__
#define __LIBMEMCACHED_ANALYZE_H__
struct memcached_analysis_st {
memcached_st *root;
uint32_t average_item_size;
uint32_t longest_uptime;
uint32_t least_free_server;
uint32_t most_consumed_server;
uint32_t oldest_server;
double pool_hit_ratio;
uint64_t most_used_bytes;
uint64_t least_remaining_bytes;
};
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_analysis_st *memcached_analyze(memcached_st *memc,
memcached_stat_st *memc_stat,
memcached_return_t *error);
LIBMEMCACHED_API
void memcached_analyze_free(memcached_analysis_st *);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_ANALYZE_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Change the behavior of the memcached connection.
*
*/
#ifndef __LIBMEMCACHED_AUTO_H__
#define __LIBMEMCACHED_AUTO_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_return_t memcached_increment(memcached_st *ptr,
const char *key, size_t key_length,
uint32_t offset,
uint64_t *value);
LIBMEMCACHED_API
memcached_return_t memcached_decrement(memcached_st *ptr,
const char *key, size_t key_length,
uint32_t offset,
uint64_t *value);
LIBMEMCACHED_API
memcached_return_t memcached_increment_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
uint64_t offset,
uint64_t *value);
LIBMEMCACHED_API
memcached_return_t memcached_decrement_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
uint64_t offset,
uint64_t *value);
LIBMEMCACHED_API
memcached_return_t 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);
LIBMEMCACHED_API
memcached_return_t 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);
LIBMEMCACHED_API
memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr,
const char *master_key,
size_t master_key_length,
const char *key,
size_t key_length,
uint64_t offset,
uint64_t initial,
time_t expiration,
uint64_t *value);
LIBMEMCACHED_API
memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *ptr,
const char *master_key,
size_t master_key_length,
const char *key,
size_t key_length,
uint64_t offset,
uint64_t initial,
time_t expiration,
uint64_t *value);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_AUTO_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Change the behavior of the memcached connection.
*
*/
#ifndef __LIBMEMCACHED_BEHAVIOR_H__
#define __LIBMEMCACHED_BEHAVIOR_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_return_t memcached_behavior_set(memcached_st *ptr, const memcached_behavior_t flag, uint64_t data);
LIBMEMCACHED_API
uint64_t memcached_behavior_get(memcached_st *ptr, const memcached_behavior_t flag);
LIBMEMCACHED_API
memcached_return_t memcached_behavior_set_distribution(memcached_st *ptr, memcached_server_distribution_t type);
LIBMEMCACHED_API
memcached_server_distribution_t memcached_behavior_get_distribution(memcached_st *ptr);
LIBMEMCACHED_API
memcached_return_t memcached_behavior_set_key_hash(memcached_st *ptr, memcached_hash_t type);
LIBMEMCACHED_API
memcached_hash_t memcached_behavior_get_key_hash(memcached_st *ptr);
LIBMEMCACHED_API
memcached_return_t memcached_behavior_set_distribution_hash(memcached_st *ptr, memcached_hash_t type);
LIBMEMCACHED_API
memcached_hash_t memcached_behavior_get_distribution_hash(memcached_st *ptr);
LIBMEMCACHED_LOCAL
bool _is_auto_eject_host(const memcached_st *ptr);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_BEHAVIOR_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary:
*
*/
#ifndef __LIBMEMCACHED_BYTEORDER_H__
#define __LIBMEMCACHED_BYTEORDER_H__
#include "config.h"
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
/* Define this here, which will turn on the visibilty controls while we're
* building libmemcached.
*/
#define BUILDING_LIBMEMCACHED 1
#include "libmemcached/memcached.h"
#ifndef HAVE_HTONLL
#define ntohll(a) memcached_ntohll(a)
#define htonll(a) memcached_htonll(a)
LIBMEMCACHED_LOCAL
uint64_t memcached_ntohll(uint64_t);
LIBMEMCACHED_LOCAL
uint64_t memcached_htonll(uint64_t);
#endif
#ifdef linux
/* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to
* optimize the conversion functions, but the prototypes generate warnings
* from gcc. The conversion methods isn't the bottleneck for my app, so
* just remove the warnings by undef'ing the optimization ..
*/
#undef ntohs
#undef ntohl
#undef htons
#undef htonl
#endif
#endif /*__LIBMEMCACHED_BYTEORDER_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Change any of the possible callbacks.
*
*/
#ifndef __LIBMEMCACHED_CALLBACK_H__
#define __LIBMEMCACHED_CALLBACK_H__
struct memcached_callback_st {
memcached_execute_fn *callback;
void *context;
uint32_t number_of_callback;
};
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_return_t memcached_callback_set(memcached_st *ptr,
const memcached_callback_t flag,
void *data);
LIBMEMCACHED_API
void *memcached_callback_get(memcached_st *ptr,
const memcached_callback_t flag,
memcached_return_t *error);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_CALLBACK_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary:
*
*/
/*
Common include file for libmemached
*/
#ifndef __LIBMEMCACHED_COMMON_H__
#define __LIBMEMCACHED_COMMON_H__
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
//#include <sys/types.h>
//#include <sys/socket.h>
//#include <netinet/in.h>
//#include <arpa/inet.h>
//#include <netdb.h>
//#include <unistd.h>
//#include <limits.h>
//#include <errno.h>
//#include <fcntl.h>
//#include <sys/un.h>
//#include <netinet/tcp.h>
#define LIBMEMCACHED_VERSION_STRING "@VERSION@"
//#include <errno.h>
#ifdef WIN32
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#include <winsock2.h>
#include <windows.h>
#include <process.h>
#include <stdio.h>
#include <mswsock.h>
#include <ws2tcpip.h>
#include <io.h>
#include "wrappers.h"
#include <sys/time.h>
//#include "timeofday.h"
#else
#include <netdb.h>
#include <netinet/in.h>
#include <sys/types.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
//typedef uint16_t in_port_t;
//typedef uint32_t in_addr_t;
/* Define this here, which will turn on the visibilty controls while we're
* building libmemcached.
*/
#define BUILDING_LIBMEMCACHED 1
#include "libmemcached/memcached.h"
#include "libmemcached/watchpoint.h"
typedef struct memcached_server_st * memcached_server_write_instance_st;
typedef memcached_return_t (*memcached_server_execute_fn)(memcached_st *ptr, memcached_server_write_instance_st server, void *context);
LIBMEMCACHED_LOCAL
memcached_server_write_instance_st memcached_server_instance_fetch(memcached_st *ptr, uint32_t server_key);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_server_execute(memcached_st *ptr,
memcached_server_execute_fn callback,
void *context);
/* These are private not to be installed headers */
#include "libmemcached/io.h"
#include "libmemcached/do.h"
#include "libmemcached/internal.h"
#include "libmemcached/libmemcached_probes.h"
#include "libmemcached/memcached/protocol_binary.h"
#include "libmemcached/byteorder.h"
#include "libmemcached/response.h"
/* string value */
struct memcached_continuum_item_st
{
uint32_t index;
uint32_t value;
};
/* Yum, Fortran.... can you make the reference? */
typedef enum {
MEM_NOT= -1,
MEM_FALSE= false,
MEM_TRUE= true
} memcached_ternary_t;
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
#define likely(x) if((x))
#define unlikely(x) if((x))
#else
#define likely(x) if(__builtin_expect((x) != 0, 1))
#define unlikely(x) if(__builtin_expect((x) != 0, 0))
#endif
#define MEMCACHED_BLOCK_SIZE 1024
#define MEMCACHED_DEFAULT_COMMAND_SIZE 350
#define SMALL_STRING_LEN 1024
#define HUGE_STRING_LEN 8196
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_LOCAL
memcached_return_t memcached_connect(memcached_server_write_instance_st ptr);
LIBMEMCACHED_LOCAL
memcached_return_t run_distribution(memcached_st *ptr);
#define memcached_server_response_increment(A) (A)->cursor_active++
#define memcached_server_response_decrement(A) (A)->cursor_active--
#define memcached_server_response_reset(A) (A)->cursor_active=0
// These are private
#define memcached_is_allocated(__object) ((__object)->options.is_allocated)
#define memcached_is_initialized(__object) ((__object)->options.is_initialized)
#define memcached_is_purging(__object) ((__object)->state.is_purging)
#define memcached_is_processing_input(__object) ((__object)->state.is_processing_input)
#define memcached_set_purging(__object, __value) ((__object)->state.is_purging= (__value))
#define memcached_set_processing_input(__object, __value) ((__object)->state.is_processing_input= (__value))
#define memcached_set_initialized(__object, __value) ((__object)->options.is_initialized(= (__value))
#define memcached_set_allocated(__object, __value) ((__object)->options.is_allocated(= (__value))
LIBMEMCACHED_LOCAL
void set_last_disconnected_host(memcached_server_write_instance_st ptr);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_key_test(const char * const *keys,
const size_t *key_length,
size_t number_of_keys);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_purge(memcached_server_write_instance_st ptr);
LIBMEMCACHED_LOCAL
memcached_server_st *memcached_server_create_with(const memcached_st *memc,
memcached_server_write_instance_st host,
const char *hostname,
in_port_t port,
uint32_t weight,
memcached_connection_t type);
static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool binary)
{
unlikely (key_length == 0)
return MEMCACHED_BAD_KEY_PROVIDED;
if (binary)
{
unlikely (key_length > 0xffff)
return MEMCACHED_BAD_KEY_PROVIDED;
}
else
{
unlikely (key_length >= MEMCACHED_MAX_KEY)
return MEMCACHED_BAD_KEY_PROVIDED;
}
return MEMCACHED_SUCCESS;
}
#ifdef TCP_CORK
#define CORK TCP_CORK
#elif defined TCP_NOPUSH
#define CORK TCP_NOPUSH
#endif
/*
test_cork() tries to enable TCP_CORK. IF TCP_CORK is not an option
on the system it returns false but sets errno to 0. Otherwise on
failure errno is set.
*/
static inline memcached_ternary_t test_cork(memcached_server_st *ptr, int enable)
{
#ifdef CORK
if (ptr->type != MEMCACHED_CONNECTION_TCP)
return MEM_FALSE;
int err= setsockopt(ptr->fd, IPPROTO_TCP, CORK,
&enable, (socklen_t)sizeof(int));
if (! err)
{
return MEM_TRUE;
}
perror(strerror(errno));
ptr->cached_errno= errno;
return MEM_FALSE;
#else
(void)ptr;
(void)enable;
ptr->cached_errno= 0;
return MEM_NOT;
#endif
}
static inline void libmemcached_free(const memcached_st *ptr, void *mem)
{
ptr->allocators.free(ptr, mem, ptr->allocators.context);
}
static inline void *libmemcached_malloc(const memcached_st *ptr, const size_t size)
{
return ptr->allocators.malloc(ptr, size, ptr->allocators.context);
}
static inline void *libmemcached_realloc(const memcached_st *ptr, void *mem, const size_t size)
{
return ptr->allocators.realloc(ptr, mem, size, ptr->allocators.context);
}
static inline void *libmemcached_calloc(const memcached_st *ptr, size_t nelem, size_t size)
{
return ptr->allocators.calloc(ptr, nelem, size, ptr->allocators.context);
}
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_COMMON_H__ */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `clock_gettime' function. */
#undef HAVE_CLOCK_GETTIME
/* Define to 1 to use the syscall interface for clock_gettime */
#undef HAVE_CLOCK_SYSCALL
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the `epoll_ctl' function. */
#undef HAVE_EPOLL_CTL
/* Define to 1 if you have the `eventfd' function. */
#undef HAVE_EVENTFD
/* Define to 1 if the floor function is available */
#define HAVE_FLOOR 1
/* Define to 1 if you have the `inotify_init' function. */
#undef HAVE_INOTIFY_INIT
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `kqueue' function. */
#undef HAVE_KQUEUE
/* Define to 1 if you have the `rt' library (-lrt). */
#undef HAVE_LIBRT
/* Define to 1 if you have the <memory.h> header file. */
//#undef HAVE_MEMORY_H
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `nanosleep' function. */
#undef HAVE_NANOSLEEP
/* Define to 1 if you have the `poll' function. */
#undef HAVE_POLL
/* Define to 1 if you have the <poll.h> header file. */
#undef HAVE_POLL_H
/* Define to 1 if you have the `port_create' function. */
#undef HAVE_PORT_CREATE
/* Define to 1 if you have the <port.h> header file. */
#undef HAVE_PORT_H
/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT
/* Define to 1 if you have the `signalfd' function. */
#undef HAVE_SIGNALFD
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/epoll.h> header file. */
#undef HAVE_SYS_EPOLL_H
/* Define to 1 if you have the <sys/eventfd.h> header file. */
#undef HAVE_SYS_EVENTFD_H
/* Define to 1 if you have the <sys/event.h> header file. */
#undef HAVE_SYS_EVENT_H
/* Define to 1 if you have the <sys/inotify.h> header file. */
#undef HAVE_SYS_INOTIFY_H
/* Define to 1 if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define to 1 if you have the <sys/signalfd.h> header file. */
#undef HAVE_SYS_SIGNALFD_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
//#define HAVE_UNISTD_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Constants for libmemcached
*
*/
#ifndef __LIBMEMCACHED_CONSTANTS_H__
#define __LIBMEMCACHED_CONSTANTS_H__
/* Public defines */
#define MEMCACHED_DEFAULT_PORT 11211
#define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */
#define MEMCACHED_MAX_BUFFER 8196
#define MEMCACHED_MAX_HOST_SORT_LENGTH 86 /* Used for Ketama */
#define MEMCACHED_POINTS_PER_SERVER 100
#define MEMCACHED_POINTS_PER_SERVER_KETAMA 160
#define MEMCACHED_CONTINUUM_SIZE MEMCACHED_POINTS_PER_SERVER*100 /* This would then set max hosts to 100 */
#define MEMCACHED_STRIDE 4
#define MEMCACHED_DEFAULT_TIMEOUT 5000
#define MEMCACHED_DEFAULT_CONNECT_TIMEOUT 4000
#define MEMCACHED_CONTINUUM_ADDITION 10 /* How many extra slots we should build for in the continuum */
#define MEMCACHED_PREFIX_KEY_MAX_SIZE 128
#define MEMCACHED_EXPIRATION_NOT_ADD 0xffffffffU
#define MEMCACHED_VERSION_STRING_LENGTH 24
typedef enum {
MEMCACHED_SUCCESS,
MEMCACHED_FAILURE,
MEMCACHED_HOST_LOOKUP_FAILURE,
MEMCACHED_CONNECTION_FAILURE,
MEMCACHED_CONNECTION_BIND_FAILURE,
MEMCACHED_WRITE_FAILURE,
MEMCACHED_READ_FAILURE,
MEMCACHED_UNKNOWN_READ_FAILURE,
MEMCACHED_PROTOCOL_ERROR,
MEMCACHED_CLIENT_ERROR,
MEMCACHED_SERVER_ERROR,
MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE,
MEMCACHED_DATA_EXISTS,
MEMCACHED_DATA_DOES_NOT_EXIST,
MEMCACHED_NOTSTORED,
MEMCACHED_STORED,
MEMCACHED_NOTFOUND,
MEMCACHED_MEMORY_ALLOCATION_FAILURE,
MEMCACHED_PARTIAL_READ,
MEMCACHED_SOME_ERRORS,
MEMCACHED_NO_SERVERS,
MEMCACHED_END,
MEMCACHED_DELETED,
MEMCACHED_VALUE,
MEMCACHED_STAT,
MEMCACHED_ITEM,
MEMCACHED_ERRNO,
MEMCACHED_FAIL_UNIX_SOCKET,
MEMCACHED_NOT_SUPPORTED,
MEMCACHED_NO_KEY_PROVIDED, /* Deprecated. Use MEMCACHED_BAD_KEY_PROVIDED! */
MEMCACHED_FETCH_NOTFINISHED,
MEMCACHED_TIMEOUT,
MEMCACHED_BUFFERED,
MEMCACHED_BAD_KEY_PROVIDED,
MEMCACHED_INVALID_HOST_PROTOCOL,
MEMCACHED_SERVER_MARKED_DEAD,
MEMCACHED_UNKNOWN_STAT_KEY,
MEMCACHED_E2BIG,
MEMCACHED_INVALID_ARGUMENTS,
MEMCACHED_KEY_TOO_BIG,
MEMCACHED_AUTH_PROBLEM,
MEMCACHED_AUTH_FAILURE,
MEMCACHED_AUTH_CONTINUE,
MEMCACHED_MAXIMUM_RETURN /* Always add new error code before */
} memcached_return_t;
typedef enum {
MEMCACHED_DISTRIBUTION_MODULA,
MEMCACHED_DISTRIBUTION_CONSISTENT,
MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA,
MEMCACHED_DISTRIBUTION_RANDOM,
MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY,
MEMCACHED_DISTRIBUTION_CONSISTENT_MAX
} memcached_server_distribution_t;
typedef enum {
MEMCACHED_BEHAVIOR_NO_BLOCK,
MEMCACHED_BEHAVIOR_TCP_NODELAY,
MEMCACHED_BEHAVIOR_HASH,
MEMCACHED_BEHAVIOR_KETAMA,
MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE,
MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE,
MEMCACHED_BEHAVIOR_CACHE_LOOKUPS,
MEMCACHED_BEHAVIOR_SUPPORT_CAS,
MEMCACHED_BEHAVIOR_POLL_TIMEOUT,
MEMCACHED_BEHAVIOR_DISTRIBUTION,
MEMCACHED_BEHAVIOR_BUFFER_REQUESTS,
MEMCACHED_BEHAVIOR_USER_DATA,
MEMCACHED_BEHAVIOR_SORT_HOSTS,
MEMCACHED_BEHAVIOR_VERIFY_KEY,
MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT,
MEMCACHED_BEHAVIOR_RETRY_TIMEOUT,
MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED,
MEMCACHED_BEHAVIOR_KETAMA_HASH,
MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
MEMCACHED_BEHAVIOR_SND_TIMEOUT,
MEMCACHED_BEHAVIOR_RCV_TIMEOUT,
MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT,
MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK,
MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK,
MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH,
MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY,
MEMCACHED_BEHAVIOR_NOREPLY,
MEMCACHED_BEHAVIOR_USE_UDP,
MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS,
MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS,
MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ,
MEMCACHED_BEHAVIOR_CORK,
MEMCACHED_BEHAVIOR_TCP_KEEPALIVE,
MEMCACHED_BEHAVIOR_TCP_KEEPIDLE,
MEMCACHED_BEHAVIOR_MAX
} memcached_behavior_t;
typedef enum {
MEMCACHED_CALLBACK_PREFIX_KEY = 0,
MEMCACHED_CALLBACK_USER_DATA = 1,
MEMCACHED_CALLBACK_CLEANUP_FUNCTION = 2,
MEMCACHED_CALLBACK_CLONE_FUNCTION = 3,
#ifdef MEMCACHED_ENABLE_DEPRECATED
MEMCACHED_CALLBACK_MALLOC_FUNCTION = 4,
MEMCACHED_CALLBACK_REALLOC_FUNCTION = 5,
MEMCACHED_CALLBACK_FREE_FUNCTION = 6,
#endif
MEMCACHED_CALLBACK_GET_FAILURE = 7,
MEMCACHED_CALLBACK_DELETE_TRIGGER = 8,
MEMCACHED_CALLBACK_MAX
} memcached_callback_t;
typedef enum {
MEMCACHED_HASH_DEFAULT= 0,
MEMCACHED_HASH_MD5,
MEMCACHED_HASH_CRC,
MEMCACHED_HASH_FNV1_64,
MEMCACHED_HASH_FNV1A_64,
MEMCACHED_HASH_FNV1_32,
MEMCACHED_HASH_FNV1A_32,
MEMCACHED_HASH_HSIEH,
MEMCACHED_HASH_MURMUR,
MEMCACHED_HASH_JENKINS,
MEMCACHED_HASH_CUSTOM,
MEMCACHED_HASH_MAX
} memcached_hash_t;
typedef enum {
MEMCACHED_CONNECTION_UNKNOWN,
MEMCACHED_CONNECTION_TCP,
MEMCACHED_CONNECTION_UDP,
MEMCACHED_CONNECTION_UNIX_SOCKET,
MEMCACHED_CONNECTION_MAX
} memcached_connection_t;
#endif /* __LIBMEMCACHED_CONSTANTS_H__ */
/* LibMemcached
* Copyright (C) 2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Delete a key from the server.
*
*/
#ifndef __LIBMEMCACHED_DELETE_H__
#define __LIBMEMCACHED_DELETE_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_return_t memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
time_t expiration);
LIBMEMCACHED_API
memcached_return_t memcached_delete_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
time_t expiration);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_DELETE_H__ */
/* LibMemcached
* Copyright (C) 2006-2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Internal functions used by the library. Not for public use!
*
*/
#ifndef __LIBMEMCACHED_DO_H__
#define __LIBMEMCACHED_DO_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_LOCAL
memcached_return_t memcached_do(memcached_server_write_instance_st ptr,
const void *commmand,
size_t command_length,
bool with_flush);
LIBMEMCACHED_LOCAL
memcached_return_t memcached_vdo(memcached_server_write_instance_st ptr,
const struct libmemcached_io_vector_st *vector, size_t count,
bool with_flush);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_DO_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Simple method for dumping data from Memcached.
*
*/
#ifndef __LIBMEMCACHED_DUMP_H__
#define __LIBMEMCACHED_DUMP_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_return_t memcached_dump(memcached_st *ptr, memcached_dump_fn *function, void *context, uint32_t number_of_callbacks);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_DUMP_H__ */
/* LibMemcached
* Copyright (C) 2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Work with fetching results
*
*/
#ifndef __LIBMEMCACHED_FETCH_H__
#define __LIBMEMCACHED_FETCH_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_return_t memcached_fetch_execute(memcached_st *ptr,
memcached_execute_fn *callback,
void *context,
uint32_t number_of_callbacks);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_FETCH_H__ */
/* LibMemcached
* Copyright (C) 2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Flush connections.
*
*/
#ifndef __LIBMEMCACHED_FLUSH_H__
#define __LIBMEMCACHED_FLUSH_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_FLUSH_H__ */
/* LibMemcached
* Copyright (C) 2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Work with fetching results
*
*/
#ifndef __LIBMEMCACHED_FLUSH_BUFFERS_H__
#define __LIBMEMCACHED_FLUSH_BUFFERS_H__
#ifdef __cplusplus
extern "C" {
#endif
LIBMEMCACHED_API
memcached_return_t memcached_flush_buffers(memcached_st *mem);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_FLUSH_BUFFERS_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Get functions for libmemcached
*
*/
#ifndef __LIBMEMCACHED_GET_H__
#define __LIBMEMCACHED_GET_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Public defines */
LIBMEMCACHED_API
char *memcached_get(memcached_st *ptr,
const char *key, size_t key_length,
size_t *value_length,
uint32_t *flags,
memcached_return_t *error);
LIBMEMCACHED_API
memcached_return_t memcached_mget(memcached_st *ptr,
const char * const *keys,
const size_t *key_length,
size_t number_of_keys);
LIBMEMCACHED_API
char *memcached_get_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
size_t *value_length,
uint32_t *flags,
memcached_return_t *error);
LIBMEMCACHED_API
memcached_return_t memcached_mget_by_key(memcached_st *ptr,
const char *master_key,
size_t master_key_length,
const char * const *keys,
const size_t *key_length,
const size_t number_of_keys);
LIBMEMCACHED_API
char *memcached_fetch(memcached_st *ptr,
char *key,
size_t *key_length,
size_t *value_length,
uint32_t *flags,
memcached_return_t *error);
LIBMEMCACHED_API
memcached_result_st *memcached_fetch_result(memcached_st *ptr,
memcached_result_st *result,
memcached_return_t *error);
LIBMEMCACHED_API
memcached_return_t memcached_mget_execute(memcached_st *ptr,
const char * const *keys,
const size_t *key_length,
const size_t number_of_keys,
memcached_execute_fn *callback,
void *context,
const uint32_t number_of_callbacks);
LIBMEMCACHED_API
memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr,
const char *master_key,
size_t master_key_length,
const char * const *keys,
const size_t *key_length,
size_t number_of_keys,
memcached_execute_fn *callback,
void *context,
const uint32_t number_of_callbacks);
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_GET_H__ */
/* LibMemcached
* Copyright (C) 2010 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: hash interface code
*
*/
#ifndef __MEMCACHED_HASH_H__
#define __MEMCACHED_HASH_H__
#ifdef __cplusplus
extern "C" {
#endif
/* 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
const hashkit_st *memcached_get_hashkit(const memcached_st *ptr);
LIBMEMCACHED_API
memcached_return_t memcached_set_hashkit(memcached_st *ptr, hashkit_st *hashk);
LIBMEMCACHED_API
uint32_t memcached_generate_hash(const memcached_st *ptr, const char *key, size_t key_length);
LIBMEMCACHED_LOCAL
uint32_t memcached_generate_hash_with_redistribution(memcached_st *ptr, const char *key, size_t key_length);
LIBMEMCACHED_API
void memcached_autoeject(memcached_st *ptr);
#ifdef __cplusplus
}
#endif
#endif /* __MEMCACHED_HASH_H__ */
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Internal functions used by the library. Not for public use!
*
*/
#ifndef __LIBMEMCACHED_INTERNAL_H__
#define __LIBMEMCACHED_INTERNAL_H__
#if defined(BUILDING_LIBMEMCACHED)
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* BUILDING_LIBMEMCACHED */
#endif /* __LIBMEMCACHED_INTERNAL_H__ */