Update for virtual buckets/wasn't this just originally the wheel?
[m6w6/libmemcached] / libmemcached / constants.h
1 /* LibMemcached
2 * Copyright (C) 2006-2009 Brian Aker
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 *
8 * Summary: Constants for libmemcached
9 *
10 */
11
12 #pragma once
13 #ifndef __LIBMEMCACHED_CONSTANTS_H__
14 #define __LIBMEMCACHED_CONSTANTS_H__
15
16 /* Public defines */
17 #define MEMCACHED_DEFAULT_PORT 11211
18 #define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */
19 #define MEMCACHED_MAX_BUFFER 8196
20 #define MEMCACHED_MAX_HOST_SORT_LENGTH 86 /* Used for Ketama */
21 #define MEMCACHED_POINTS_PER_SERVER 100
22 #define MEMCACHED_POINTS_PER_SERVER_KETAMA 160
23 #define MEMCACHED_CONTINUUM_SIZE MEMCACHED_POINTS_PER_SERVER*100 /* This would then set max hosts to 100 */
24 #define MEMCACHED_STRIDE 4
25 #define MEMCACHED_DEFAULT_TIMEOUT 5000
26 #define MEMCACHED_DEFAULT_CONNECT_TIMEOUT 4000
27 #define MEMCACHED_CONTINUUM_ADDITION 10 /* How many extra slots we should build for in the continuum */
28 #define MEMCACHED_PREFIX_KEY_MAX_SIZE 128
29 #define MEMCACHED_EXPIRATION_NOT_ADD 0xffffffffU
30 #define MEMCACHED_VERSION_STRING_LENGTH 24
31
32
33 enum memcached_return_t {
34 MEMCACHED_SUCCESS,
35 MEMCACHED_FAILURE,
36 MEMCACHED_HOST_LOOKUP_FAILURE,
37 MEMCACHED_CONNECTION_FAILURE,
38 MEMCACHED_CONNECTION_BIND_FAILURE,
39 MEMCACHED_WRITE_FAILURE,
40 MEMCACHED_READ_FAILURE,
41 MEMCACHED_UNKNOWN_READ_FAILURE,
42 MEMCACHED_PROTOCOL_ERROR,
43 MEMCACHED_CLIENT_ERROR,
44 MEMCACHED_SERVER_ERROR,
45 MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE,
46 MEMCACHED_DATA_EXISTS,
47 MEMCACHED_DATA_DOES_NOT_EXIST,
48 MEMCACHED_NOTSTORED,
49 MEMCACHED_STORED,
50 MEMCACHED_NOTFOUND,
51 MEMCACHED_MEMORY_ALLOCATION_FAILURE,
52 MEMCACHED_PARTIAL_READ,
53 MEMCACHED_SOME_ERRORS,
54 MEMCACHED_NO_SERVERS,
55 MEMCACHED_END,
56 MEMCACHED_DELETED,
57 MEMCACHED_VALUE,
58 MEMCACHED_STAT,
59 MEMCACHED_ITEM,
60 MEMCACHED_ERRNO,
61 MEMCACHED_FAIL_UNIX_SOCKET,
62 MEMCACHED_NOT_SUPPORTED,
63 MEMCACHED_NO_KEY_PROVIDED, /* Deprecated. Use MEMCACHED_BAD_KEY_PROVIDED! */
64 MEMCACHED_FETCH_NOTFINISHED,
65 MEMCACHED_TIMEOUT,
66 MEMCACHED_BUFFERED,
67 MEMCACHED_BAD_KEY_PROVIDED,
68 MEMCACHED_INVALID_HOST_PROTOCOL,
69 MEMCACHED_SERVER_MARKED_DEAD,
70 MEMCACHED_UNKNOWN_STAT_KEY,
71 MEMCACHED_E2BIG,
72 MEMCACHED_INVALID_ARGUMENTS,
73 MEMCACHED_KEY_TOO_BIG,
74 MEMCACHED_AUTH_PROBLEM,
75 MEMCACHED_AUTH_FAILURE,
76 MEMCACHED_AUTH_CONTINUE,
77 MEMCACHED_PARSE_ERROR,
78 MEMCACHED_PARSE_USER_ERROR,
79 MEMCACHED_MAXIMUM_RETURN /* Always add new error code before */
80 };
81
82 #ifndef __cplusplus
83 typedef enum memcached_return_t memcached_return_t;
84 #endif
85
86
87 enum memcached_server_distribution_t {
88 MEMCACHED_DISTRIBUTION_MODULA,
89 MEMCACHED_DISTRIBUTION_CONSISTENT,
90 MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA,
91 MEMCACHED_DISTRIBUTION_RANDOM,
92 MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY,
93 MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED,
94 MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET,
95 MEMCACHED_DISTRIBUTION_CONSISTENT_MAX
96 };
97
98 #ifndef __cplusplus
99 typedef enum memcached_server_distribution_t memcached_server_distribution_t;
100 #endif
101
102 typedef enum {
103 MEMCACHED_BEHAVIOR_NO_BLOCK,
104 MEMCACHED_BEHAVIOR_TCP_NODELAY,
105 MEMCACHED_BEHAVIOR_HASH,
106 MEMCACHED_BEHAVIOR_KETAMA,
107 MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE,
108 MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE,
109 MEMCACHED_BEHAVIOR_CACHE_LOOKUPS,
110 MEMCACHED_BEHAVIOR_SUPPORT_CAS,
111 MEMCACHED_BEHAVIOR_POLL_TIMEOUT,
112 MEMCACHED_BEHAVIOR_DISTRIBUTION,
113 MEMCACHED_BEHAVIOR_BUFFER_REQUESTS,
114 MEMCACHED_BEHAVIOR_USER_DATA,
115 MEMCACHED_BEHAVIOR_SORT_HOSTS,
116 MEMCACHED_BEHAVIOR_VERIFY_KEY,
117 MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT,
118 MEMCACHED_BEHAVIOR_RETRY_TIMEOUT,
119 MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED,
120 MEMCACHED_BEHAVIOR_KETAMA_HASH,
121 MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
122 MEMCACHED_BEHAVIOR_SND_TIMEOUT,
123 MEMCACHED_BEHAVIOR_RCV_TIMEOUT,
124 MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT,
125 MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK,
126 MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK,
127 MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH,
128 MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY,
129 MEMCACHED_BEHAVIOR_NOREPLY,
130 MEMCACHED_BEHAVIOR_USE_UDP,
131 MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS,
132 MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS,
133 MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ,
134 MEMCACHED_BEHAVIOR_CORK,
135 MEMCACHED_BEHAVIOR_TCP_KEEPALIVE,
136 MEMCACHED_BEHAVIOR_TCP_KEEPIDLE,
137 MEMCACHED_BEHAVIOR_LOAD_FROM_FILE,
138 MEMCACHED_BEHAVIOR_MAX
139 } memcached_behavior_t;
140
141 typedef enum {
142 MEMCACHED_CALLBACK_PREFIX_KEY = 0,
143 MEMCACHED_CALLBACK_USER_DATA = 1,
144 MEMCACHED_CALLBACK_CLEANUP_FUNCTION = 2,
145 MEMCACHED_CALLBACK_CLONE_FUNCTION = 3,
146 #ifdef MEMCACHED_ENABLE_DEPRECATED
147 MEMCACHED_CALLBACK_MALLOC_FUNCTION = 4,
148 MEMCACHED_CALLBACK_REALLOC_FUNCTION = 5,
149 MEMCACHED_CALLBACK_FREE_FUNCTION = 6,
150 #endif
151 MEMCACHED_CALLBACK_GET_FAILURE = 7,
152 MEMCACHED_CALLBACK_DELETE_TRIGGER = 8,
153 MEMCACHED_CALLBACK_MAX
154 } memcached_callback_t;
155
156 typedef enum {
157 MEMCACHED_HASH_DEFAULT= 0,
158 MEMCACHED_HASH_MD5,
159 MEMCACHED_HASH_CRC,
160 MEMCACHED_HASH_FNV1_64,
161 MEMCACHED_HASH_FNV1A_64,
162 MEMCACHED_HASH_FNV1_32,
163 MEMCACHED_HASH_FNV1A_32,
164 MEMCACHED_HASH_HSIEH,
165 MEMCACHED_HASH_MURMUR,
166 MEMCACHED_HASH_JENKINS,
167 MEMCACHED_HASH_CUSTOM,
168 MEMCACHED_HASH_MAX
169 } memcached_hash_t;
170
171 typedef enum {
172 MEMCACHED_CONNECTION_UNKNOWN,
173 MEMCACHED_CONNECTION_TCP,
174 MEMCACHED_CONNECTION_UDP,
175 MEMCACHED_CONNECTION_UNIX_SOCKET,
176 MEMCACHED_CONNECTION_MAX
177 } memcached_connection_t;
178
179 #endif /* __LIBMEMCACHED_CONSTANTS_H__ */