50ee60bf6606be239a375214946114bc4c42cb45
2 Common include file for libmemached
12 #include <sys/types.h>
13 #include <sys/socket.h>
14 #include <netinet/in.h>
15 #include <arpa/inet.h>
22 #include <netinet/tcp.h>
24 #if TIME_WITH_SYS_TIME
25 # include <sys/time.h>
29 # include <sys/time.h>
37 #include <memcached.h>
38 #include "memcached_io.h"
40 #include <libmemcached_config.h>
42 #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
44 #define likely(x) if((x))
45 #define unlikely(x) if((x))
49 #define likely(x) if(__builtin_expect(!!(x), 1))
50 #define unlikely(x) if(__builtin_expect((x), 0))
55 #define _DTRACE_VERSION 1
57 #undef _DTRACE_VERSION
60 #include "libmemcached_probes.h"
62 #define MEMCACHED_BLOCK_SIZE 1024
63 #define MEMCACHED_DEFAULT_COMMAND_SIZE 350
64 #define SMALL_STRING_LEN 1024
65 #define HUGE_STRING_LEN 8196
69 MEM_NO_BLOCK
= (1 << 0),
70 MEM_TCP_NODELAY
= (1 << 1),
71 MEM_REUSE_MEMORY
= (1 << 2),
72 MEM_USE_MD5
= (1 << 3),
73 MEM_USE_KETAMA
= (1 << 4),
74 MEM_USE_CRC
= (1 << 5),
75 MEM_USE_CACHE_LOOKUPS
= (1 << 6),
76 MEM_SUPPORT_CAS
= (1 << 7),
77 MEM_BUFFER_REQUESTS
= (1 << 8),
78 MEM_USE_SORT_HOSTS
= (1 << 9),
79 MEM_VERIFY_KEY
= (1 << 10),
83 void md5_signature(unsigned char *key
, unsigned int length
, unsigned char *result
);
84 uint32_t hash_crc32(const char *data
,
86 uint32_t hsieh_hash(char *key
, size_t key_length
);
87 uint32_t murmur_hash(char *key
, size_t key_length
);
89 memcached_return
memcached_connect(memcached_server_st
*ptr
);
90 memcached_return
memcached_response(memcached_server_st
*ptr
,
91 char *buffer
, size_t buffer_length
,
92 memcached_result_st
*result
);
93 unsigned int memcached_generate_hash(memcached_st
*ptr
, char *key
, size_t key_length
);
94 void memcached_quit_server(memcached_server_st
*ptr
, uint8_t io_death
);
96 #define memcached_server_response_increment(A) (A)->cursor_active++
97 #define memcached_server_response_decrement(A) (A)->cursor_active--
98 #define memcached_server_response_reset(A) (A)->cursor_active=0
100 memcached_return
memcached_do(memcached_server_st
*ptr
, char *commmand
,
101 size_t command_length
, uint8_t with_flush
);
102 memcached_return
memcached_version(memcached_st
*ptr
);
103 memcached_return
value_fetch(memcached_server_st
*ptr
,
105 memcached_result_st
*result
);
106 void server_list_free(memcached_st
*ptr
, memcached_server_st
*servers
);
108 memcached_return
memcachd_key_test(char **keys
, size_t *key_length
,
109 unsigned int number_of_keys
);
111 memcached_return
run_distribution(memcached_st
*ptr
);
113 uint32_t generate_hash(memcached_st
*ptr
, char *key
, size_t key_length
);
114 #endif /* __COMMON_H__ */