Ignore *.exe
[awesomized/libmemcached] / docs / memcached_behavior.pod
1 =head1 NAME
2
3 memcached_behavior_get, memcached_behavior_set - Manipulate behavior
4
5 =head1 LIBRARY
6
7 C Client Library for memcached (libmemcached, -lmemcached)
8
9 =head1 SYNOPSIS
10
11 #include <memcached.h>
12
13 uint64_t
14 memcached_behavior_get (memcached_st *ptr,
15 memcached_behavior flag);
16
17 memcached_return_t
18 memcached_behavior_set (memcached_st *ptr,
19 memcached_behavior flag,
20 uint64_t data);
21
22 =head1 DESCRIPTION
23
24 libmemcached(3) behavior can be modified by use memcached_behavior_set().
25 Default behavior is the library strives to be quick and accurate. Some
26 behavior, while being faster, can also result in not entirely accurate
27 behavior (for instance, memcached_set() will always respond with
28 C<MEMCACHED_SUCCESS>).
29
30 memcached_behavior_get() takes a behavior flag and returns whether or not
31 that behavior is currently enabled in the client.
32
33 memcached_behavior_set() changes the value of a particular option of the
34 client. It takes both a flag (listed below) and a value. For simple on or
35 off options you just need to pass in a value of 1. Calls to
36 memcached_behavior_set() will flush and reset all connections.
37
38 =over 4
39
40 =item MEMCACHED_BEHAVIOR_USE_UDP
41
42 Causes libmemcached(3) to use the UDP transport when communicating
43 with a memcached server. Not all I/O operations are supported
44 when this behavior is enababled. The following operations will return
45 C<MEMCACHED_NOT_SUPPORTED> when executed with the MEMCACHED_BEHAVIOR_USE_UDP
46 enabled: memcached_version(), memcached_stat(), memcached_get(),
47 memcached_get_by_key(), memcached_mget(), memcached_mget_by_key(),
48 memcached_fetch(), memcached_fetch_result(), memcached_value_fetch().
49
50 All other operations are supported but are executed in a 'fire-and-forget'
51 mode, in which once the client has executed the operation, no attempt
52 will be made to ensure the operation has been received and acted on by the
53 server.
54
55 libmemcached(3) does not allow TCP and UDP servers to be shared within
56 the same libmemached(3) client 'instance'. An attempt to add a TCP server
57 when this behavior is enabled will result in a C<MEMCACHED_INVALID_HOST_PROTOCOL>,
58 as will attempting to add a UDP server when this behavior has not been enabled.
59
60 =item MEMCACHED_BEHAVIOR_NO_BLOCK
61
62 Causes libmemcached(3) to use asychronous IO. This is the fastest transport
63 available for storage functions.
64
65 =item MEMCACHED_BEHAVIOR_SND_TIMEOUT
66
67 This sets the microsecond behavior of the socket against the SO_SNDTIMEO flag.
68 In cases where you cannot use non-blocking IO this will allow you to still have
69 timeouts on the sending of data.
70
71 =item MEMCACHED_BEHAVIOR_RCV_TIMEOUT
72
73 This sets the microsecond behavior of the socket against the SO_RCVTIMEO flag.
74 In cases where you cannot use non-blocking IO this will allow you to still have
75 timeouts on the reading of data.
76
77 =item MEMCACHED_BEHAVIOR_TCP_NODELAY
78
79 Turns on the no-delay feature for connecting sockets (may be faster in some
80 environments).
81
82 =item MEMCACHED_BEHAVIOR_HASH
83
84 Makes the default hashing algorithm for keys use MD5. The value can be set
85 to either MEMCACHED_HASH_DEFAULT, MEMCACHED_HASH_MD5, MEMCACHED_HASH_CRC, MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64, MEMCACHED_HASH_FNV1_32, MEMCACHED_HASH_FNV1A_32, MEMCACHED_HASH_JENKINS, MEMCACHED_HASH_HSIEH, and MEMCACHED_HASH_MURMUR.
86 Each hash has it's advantages and it's weaknesses. If you don't know or don't care, just go with the default.
87 Support for MEMCACHED_HASH_HSIEH is a compile time option that is disabled by default. To enable support for this hashing algorithm, configure and build libmemcached with the --enable-hash_hsieh.
88
89 =item MEMCACHED_BEHAVIOR_DISTRIBUTION
90
91 Using this you can enable different means of distributing values to servers.
92 The default method is MEMCACHED_DISTRIBUTION_MODULA. You can enable
93 consistent hashing by setting MEMCACHED_DISTRIBUTION_CONSISTENT.
94 Consistent hashing delivers better distribution and allows servers to be
95 added to the cluster with minimal cache losses. Currently
96 MEMCACHED_DISTRIBUTION_CONSISTENT is an alias for the value
97 MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA.
98
99 =item MEMCACHED_BEHAVIOR_CACHE_LOOKUPS
100
101 Memcached can cache named lookups so that DNS lookups are made only once.
102
103 =item MEMCACHED_BEHAVIOR_SUPPORT_CAS
104
105 Support CAS operations (this is not enabled by default at this point in the server since it imposes a slight performance penalty).
106
107 =item MEMCACHED_BEHAVIOR_KETAMA
108
109 Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA
110 and the hash to MEMCACHED_HASH_MD5.
111
112 =item MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED
113
114 Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA with the weighted support.
115 and the hash to MEMCACHED_HASH_MD5.
116
117 =item MEMCACHED_BEHAVIOR_KETAMA_HASH
118
119 Sets the hashing algorithm for host mapping on continuum. The value can be set
120 to either MEMCACHED_HASH_DEFAULT, MEMCACHED_HASH_MD5, MEMCACHED_HASH_CRC, MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64, MEMCACHED_HASH_FNV1_32, and MEMCACHED_HASH_FNV1A_32.
121
122 =item MEMCACHED_BEHAVIOR_KETAMA_COMPAT
123
124 Sets the compatibility mode. The value can be set to either
125 MEMCACHED_KETAMA_COMPAT_LIBMEMCACHED (this is the default) or
126 MEMCACHED_KETAMA_COMPAT_SPY to be compatible with the SPY Memcached client
127 for Java.
128
129 =item MEMCACHED_BEHAVIOR_POLL_TIMEOUT
130
131 Modify the timeout value that is used by poll(). The default value is -1. An signed int pointer must be passed to memcached_behavior_set() to change this value. For memcached_behavior_get() a signed int value will be cast and returned as the unsigned long long.
132
133 =item MEMCACHED_BEHAVIOR_USER_DATA
134
135 This allows you to store a pointer to a specifc piece of data. This can be
136 retrieved from inside of memcached_fetch_execute(). Cloning a memcached_st
137
138 will copy the pointer to the clone. This was deprecated in 0.14 in favor
139 of memcached_callback_set(3). This will be removed in 0.15.
140
141 =item MEMCACHED_BEHAVIOR_BUFFER_REQUESTS
142
143 Enabling buffered IO causes commands to "buffer" instead of being sent. Any
144 action that gets data causes this buffer to be be sent to the remote
145 connection. Quiting the connection or closing down the connection will also
146 cause the buffered data to be pushed to the remote connection.
147
148 =item MEMCACHED_BEHAVIOR_VERIFY_KEY
149
150 Enabling this will cause libmemcached(3) to test all keys to verify that they
151 are valid keys.
152
153 =item MEMCACHED_BEHAVIOR_SORT_HOSTS
154
155 Enabling this will cause hosts that are added to be placed in the host list in
156 sorted order. This will defeat consisten hashing.
157
158 =item MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT
159
160 In non-blocking mode this changes the value of the timeout during socket
161 connection.
162
163 =item MEMCACHED_BEHAVIOR_BINARY_PROTOCOL
164
165 Enable the use of the binary protocol. Please note that you cannot toggle
166 this flag on an open connection.
167
168 =item MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
169
170 Set this value to enable the server be removed after continuous MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
171 times connection failure.
172
173 =item MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK
174
175 Set this value to tune the number of messages that may be sent before
176 libmemcached should start to automatically drain the input queue. Setting
177 this value to high, may cause libmemcached to deadlock (trying to send data,
178 but the send will block because the input buffer in the kernel is full).
179
180 =item MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK
181
182 Set this value to tune the number of bytes that may be sent before
183 libmemcached should start to automatically drain the input queue (need
184 at least 10 IO requests sent without reading the input buffer). Setting
185 this value to high, may cause libmemcached to deadlock (trying to send
186 data, but the send will block because the input buffer in the kernel is full).
187
188 =item MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH
189
190 The binary protocol works a bit different than the textual protocol in
191 that a multiget is implemented as a pipe of single get-operations which
192 are sent to the server in a chunk. If you are using large multigets from
193 your application, you may improve the latency of the gets by setting
194 this value so you send out the first chunk of requests when you hit the
195 specified limit. It allows the servers to start processing the requests
196 to send the data back while the rest of the requests are created and
197 sent to the server.
198
199 =item MEMCACHED_BEHAVIOR_NOREPLY
200
201 Set this value to specify that you really don't care about the result
202 from your storage commands (set, add, replace, append, prepend).
203
204 =item MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS
205
206 If you just want "a poor mans HA", you may specify the numbers of
207 replicas libmemcached should store of each item (on different servers).
208 This replication does not dedicate certain memcached servers to store the
209 replicas in, but instead it will store the replicas together with all of the
210 other objects (on the 'n' next servers specified in your server list).
211
212 =item MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ
213
214 Allows randomizing the replica reads starting point. Normally the read is
215 done from primary server and in case of miss the read is done from primary
216 + 1, then primary + 2 all the way to 'n' replicas. If this option is set
217 on the starting point of the replica reads is randomized between the servers.
218 This allows distributing read load to multiple servers with the expense of
219 more write traffic.
220
221 =item MEMCACHED_BEHAVIOR_CORK
222
223 Enable TCP_CORK behavior. This is only available as an option Linux.
224 MEMCACHED_NO_SERVERS is returned if no servers are available to test with.
225 MEMCACHED_NOT_SUPPORTED is returned if we were not able to determine
226 if support was available. All other responses then MEMCACHED_SUCCESS
227 report an error of some sort. This behavior also enables
228 MEMCACHED_BEHAVIOR_TCP_NODELAY when set.
229
230 =item MEMCACHED_BEHAVIOR_KEEPALIVE
231
232 Enable TCP_KEEPALIVE behavior.
233
234 =item MEMCACHED_BEHAVIOR_KEEPALIVE_IDLE
235
236 Specify time, in seconds, to mark a connection as idle. This is only available as an option Linux.
237
238 =item MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
239
240 Find the current size of SO_SNDBUF. A value of 0 means either an error
241 occured or no hosts were available. It is safe to assume system default
242 if this occurs.
243
244 =item MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
245
246 Find the current size of SO_RCVBUF. A value of 0 means either an error
247 occured or no hosts were available. It is safe to assume system default
248 if this occurs.
249
250 =item MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
251
252 This number of times a host can have an error before it is disabled.
253
254 =item MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS
255
256 If enabled any hosts which have been flagged as disabled will be removed
257 from the list of servers in the memcached_st structure. This must be used
258 in combination with MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT.
259
260 =item MEMCACHED_BEHAVIOR_RETRY_TIMEOUT
261
262 When enabled a host which is problematic will only be checked for usage
263 based on the amount of time set by this behavior.
264
265 =back
266
267 =head1 RETURN
268
269 memcached_behavior_get() returns either the current value of the get, or 0
270 or 1 on simple flag behaviors (1 being enabled). memcached_behavior_set()
271 returns failure or success.
272
273 =head1 NOTES
274
275 memcached_behavior_set() in version .17 was changed from taking a pointer
276 to data value, to taking a uin64_t.
277
278 =head1 HOME
279
280 To find out more information please check:
281 L<https://launchpad.net/libmemcached>
282
283 =head1 AUTHOR
284
285 Brian Aker, E<lt>brian@tangent.orgE<gt>
286
287 =head1 SEE ALSO
288
289 memcached(1) libmemcached(3) memcached_strerror(3)
290
291 =cut
292