Merge in docs.
[awesomized/libmemcached] / docs / man / memcached_behavior.3
1 .TH "MEMCACHED_BEHAVIOR" "3" "April 07, 2011" "0.47" "libmemcached"
2 .SH NAME
3 memcached_behavior \- libmemcached Documentation
4 .
5 .nr rst2man-indent-level 0
6 .
7 .de1 rstReportMargin
8 \\$1 \\n[an-margin]
9 level \\n[rst2man-indent-level]
10 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
11 -
12 \\n[rst2man-indent0]
13 \\n[rst2man-indent1]
14 \\n[rst2man-indent2]
15 ..
16 .de1 INDENT
17 .\" .rstReportMargin pre:
18 . RS \\$1
19 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
20 . nr rst2man-indent-level +1
21 .\" .rstReportMargin post:
22 ..
23 .de UNINDENT
24 . RE
25 .\" indent \\n[an-margin]
26 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
27 .nr rst2man-indent-level -1
28 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
29 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
30 ..
31 .\" Man page generated from reStructeredText.
32 .
33 .sp
34 Manipulate behavior
35 .SH LIBRARY
36 .sp
37 C Client Library for memcached (libmemcached, \-lmemcached)
38 .SH SYNOPSIS
39 .sp
40 .nf
41 .ft C
42 #include <libmemcached/memcached.h>
43
44 uint64_t
45 memcached_behavior_get (memcached_st *ptr,
46 memcached_behavior flag);
47
48 memcached_return_t
49 memcached_behavior_set (memcached_st *ptr,
50 memcached_behavior flag,
51 uint64_t data);
52 .ft P
53 .fi
54 .SH DESCRIPTION
55 .sp
56 libmemcached(3) behavior can be modified by use memcached_behavior_set().
57 Default behavior is the library strives to be quick and accurate. Some
58 behavior, while being faster, can also result in not entirely accurate
59 behavior (for instance, memcached_set() will always respond with
60 \fBMEMCACHED_SUCCESS\fP).
61 .sp
62 memcached_behavior_get() takes a behavior flag and returns whether or not
63 that behavior is currently enabled in the client.
64 .sp
65 memcached_behavior_set() changes the value of a particular option of the
66 client. It takes both a flag (listed below) and a value. For simple on or
67 off options you just need to pass in a value of 1. Calls to
68 memcached_behavior_set() will flush and reset all connections.
69 .sp
70 MEMCACHED_BEHAVIOR_USE_UDP
71 .INDENT 0.0
72 .INDENT 3.5
73 .sp
74 Causes libmemcached(3) to use the UDP transport when communicating
75 with a memcached server. Not all I/O operations are supported
76 when this behavior is enababled. The following operations will return
77 \fBMEMCACHED_NOT_SUPPORTED\fP when executed with the MEMCACHED_BEHAVIOR_USE_UDP
78 enabled: memcached_version(), memcached_stat(), memcached_get(),
79 memcached_get_by_key(), memcached_mget(), memcached_mget_by_key(),
80 memcached_fetch(), memcached_fetch_result(), memcached_value_fetch().
81 .sp
82 All other operations are supported but are executed in a \(aqfire\-and\-forget\(aq
83 mode, in which once the client has executed the operation, no attempt
84 will be made to ensure the operation has been received and acted on by the
85 server.
86 .sp
87 libmemcached(3) does not allow TCP and UDP servers to be shared within
88 the same libmemached(3) client \(aqinstance\(aq. An attempt to add a TCP server
89 when this behavior is enabled will result in a \fBMEMCACHED_INVALID_HOST_PROTOCOL\fP,
90 as will attempting to add a UDP server when this behavior has not been enabled.
91 .UNINDENT
92 .UNINDENT
93 .sp
94 MEMCACHED_BEHAVIOR_NO_BLOCK
95 .INDENT 0.0
96 .INDENT 3.5
97 .sp
98 Causes libmemcached(3) to use asychronous IO. This is the fastest transport
99 available for storage functions.
100 .UNINDENT
101 .UNINDENT
102 .sp
103 MEMCACHED_BEHAVIOR_SND_TIMEOUT
104 .INDENT 0.0
105 .INDENT 3.5
106 .sp
107 This sets the microsecond behavior of the socket against the SO_SNDTIMEO flag.
108 In cases where you cannot use non\-blocking IO this will allow you to still have
109 timeouts on the sending of data.
110 .UNINDENT
111 .UNINDENT
112 .sp
113 MEMCACHED_BEHAVIOR_RCV_TIMEOUT
114 .INDENT 0.0
115 .INDENT 3.5
116 .sp
117 This sets the microsecond behavior of the socket against the SO_RCVTIMEO flag.
118 In cases where you cannot use non\-blocking IO this will allow you to still have
119 timeouts on the reading of data.
120 .UNINDENT
121 .UNINDENT
122 .sp
123 MEMCACHED_BEHAVIOR_TCP_NODELAY
124 .INDENT 0.0
125 .INDENT 3.5
126 .sp
127 Turns on the no\-delay feature for connecting sockets (may be faster in some
128 environments).
129 .UNINDENT
130 .UNINDENT
131 .sp
132 MEMCACHED_BEHAVIOR_HASH
133 .INDENT 0.0
134 .INDENT 3.5
135 .sp
136 Makes the default hashing algorithm for keys use MD5. The value can be set
137 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.
138 Each hash has it\(aqs advantages and it\(aqs weaknesses. If you don\(aqt know or don\(aqt care, just go with the default.
139 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.
140 .UNINDENT
141 .UNINDENT
142 .sp
143 MEMCACHED_BEHAVIOR_DISTRIBUTION
144 .INDENT 0.0
145 .INDENT 3.5
146 .sp
147 Using this you can enable different means of distributing values to servers.
148 The default method is MEMCACHED_DISTRIBUTION_MODULA. You can enable
149 consistent hashing by setting MEMCACHED_DISTRIBUTION_CONSISTENT.
150 Consistent hashing delivers better distribution and allows servers to be
151 added to the cluster with minimal cache losses. Currently
152 MEMCACHED_DISTRIBUTION_CONSISTENT is an alias for the value
153 MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA.
154 .UNINDENT
155 .UNINDENT
156 .sp
157 MEMCACHED_BEHAVIOR_CACHE_LOOKUPS
158 .INDENT 0.0
159 .INDENT 3.5
160 .sp
161 Memcached can cache named lookups so that DNS lookups are made only once.
162 .UNINDENT
163 .UNINDENT
164 .sp
165 MEMCACHED_BEHAVIOR_SUPPORT_CAS
166 .INDENT 0.0
167 .INDENT 3.5
168 .sp
169 Support CAS operations (this is not enabled by default at this point in the server since it imposes a slight performance penalty).
170 .UNINDENT
171 .UNINDENT
172 .sp
173 MEMCACHED_BEHAVIOR_KETAMA
174 .INDENT 0.0
175 .INDENT 3.5
176 .sp
177 Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA
178 and the hash to MEMCACHED_HASH_MD5.
179 .UNINDENT
180 .UNINDENT
181 .sp
182 MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED
183 .INDENT 0.0
184 .INDENT 3.5
185 .sp
186 Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA with the weighted support.
187 and the hash to MEMCACHED_HASH_MD5.
188 .UNINDENT
189 .UNINDENT
190 .sp
191 MEMCACHED_BEHAVIOR_KETAMA_HASH
192 .INDENT 0.0
193 .INDENT 3.5
194 .sp
195 Sets the hashing algorithm for host mapping on continuum. The value can be set
196 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.
197 .UNINDENT
198 .UNINDENT
199 .sp
200 MEMCACHED_BEHAVIOR_KETAMA_COMPAT
201 .INDENT 0.0
202 .INDENT 3.5
203 .sp
204 Sets the compatibility mode. The value can be set to either
205 MEMCACHED_KETAMA_COMPAT_LIBMEMCACHED (this is the default) or
206 MEMCACHED_KETAMA_COMPAT_SPY to be compatible with the SPY Memcached client
207 for Java.
208 .UNINDENT
209 .UNINDENT
210 .sp
211 MEMCACHED_BEHAVIOR_POLL_TIMEOUT
212 .INDENT 0.0
213 .INDENT 3.5
214 .sp
215 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.
216 .UNINDENT
217 .UNINDENT
218 .sp
219 MEMCACHED_BEHAVIOR_USER_DATA
220 .INDENT 0.0
221 .INDENT 3.5
222 .sp
223 This allows you to store a pointer to a specifc piece of data. This can be
224 retrieved from inside of memcached_fetch_execute(). Cloning a memcached_st
225 .sp
226 will copy the pointer to the clone. This was deprecated in 0.14 in favor
227 of memcached_callback_set(3). This will be removed in 0.15.
228 .UNINDENT
229 .UNINDENT
230 .sp
231 MEMCACHED_BEHAVIOR_BUFFER_REQUESTS
232 .INDENT 0.0
233 .INDENT 3.5
234 .sp
235 Enabling buffered IO causes commands to "buffer" instead of being sent. Any
236 action that gets data causes this buffer to be be sent to the remote
237 connection. Quiting the connection or closing down the connection will also
238 cause the buffered data to be pushed to the remote connection.
239 .UNINDENT
240 .UNINDENT
241 .sp
242 MEMCACHED_BEHAVIOR_VERIFY_KEY
243 .INDENT 0.0
244 .INDENT 3.5
245 .sp
246 Enabling this will cause libmemcached(3) to test all keys to verify that they
247 are valid keys.
248 .UNINDENT
249 .UNINDENT
250 .sp
251 MEMCACHED_BEHAVIOR_SORT_HOSTS
252 .INDENT 0.0
253 .INDENT 3.5
254 .sp
255 Enabling this will cause hosts that are added to be placed in the host list in
256 sorted order. This will defeat consisten hashing.
257 .UNINDENT
258 .UNINDENT
259 .sp
260 MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT
261 .INDENT 0.0
262 .INDENT 3.5
263 .sp
264 In non\-blocking mode this changes the value of the timeout during socket
265 connection.
266 .UNINDENT
267 .UNINDENT
268 .sp
269 MEMCACHED_BEHAVIOR_BINARY_PROTOCOL
270 .INDENT 0.0
271 .INDENT 3.5
272 .sp
273 Enable the use of the binary protocol. Please note that you cannot toggle
274 this flag on an open connection.
275 .UNINDENT
276 .UNINDENT
277 .sp
278 MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
279 .INDENT 0.0
280 .INDENT 3.5
281 .sp
282 Set this value to enable the server be removed after continuous MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
283 times connection failure.
284 .UNINDENT
285 .UNINDENT
286 .sp
287 MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK
288 .INDENT 0.0
289 .INDENT 3.5
290 .sp
291 Set this value to tune the number of messages that may be sent before
292 libmemcached should start to automatically drain the input queue. Setting
293 this value to high, may cause libmemcached to deadlock (trying to send data,
294 but the send will block because the input buffer in the kernel is full).
295 .UNINDENT
296 .UNINDENT
297 .sp
298 MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK
299 .INDENT 0.0
300 .INDENT 3.5
301 .sp
302 Set this value to tune the number of bytes that may be sent before
303 libmemcached should start to automatically drain the input queue (need
304 at least 10 IO requests sent without reading the input buffer). Setting
305 this value to high, may cause libmemcached to deadlock (trying to send
306 data, but the send will block because the input buffer in the kernel is full).
307 .UNINDENT
308 .UNINDENT
309 .sp
310 MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH
311 .INDENT 0.0
312 .INDENT 3.5
313 .sp
314 The binary protocol works a bit different than the textual protocol in
315 that a multiget is implemented as a pipe of single get\-operations which
316 are sent to the server in a chunk. If you are using large multigets from
317 your application, you may improve the latency of the gets by setting
318 this value so you send out the first chunk of requests when you hit the
319 specified limit. It allows the servers to start processing the requests
320 to send the data back while the rest of the requests are created and
321 sent to the server.
322 .UNINDENT
323 .UNINDENT
324 .sp
325 MEMCACHED_BEHAVIOR_NOREPLY
326 .INDENT 0.0
327 .INDENT 3.5
328 .sp
329 Set this value to specify that you really don\(aqt care about the result
330 from your storage commands (set, add, replace, append, prepend).
331 .UNINDENT
332 .UNINDENT
333 .sp
334 MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS
335 .INDENT 0.0
336 .INDENT 3.5
337 .sp
338 If you just want "a poor mans HA", you may specify the numbers of
339 replicas libmemcached should store of each item (on different servers).
340 This replication does not dedicate certain memcached servers to store the
341 replicas in, but instead it will store the replicas together with all of the
342 other objects (on the \(aqn\(aq next servers specified in your server list).
343 .UNINDENT
344 .UNINDENT
345 .sp
346 MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ
347 .INDENT 0.0
348 .INDENT 3.5
349 .sp
350 Allows randomizing the replica reads starting point. Normally the read is
351 done from primary server and in case of miss the read is done from primary
352 + 1, then primary + 2 all the way to \(aqn\(aq replicas. If this option is set
353 on the starting point of the replica reads is randomized between the servers.
354 This allows distributing read load to multiple servers with the expense of
355 more write traffic.
356 .UNINDENT
357 .UNINDENT
358 .sp
359 MEMCACHED_BEHAVIOR_CORK
360 .INDENT 0.0
361 .INDENT 3.5
362 .sp
363 Enable TCP_CORK behavior. This is only available as an option Linux.
364 MEMCACHED_NO_SERVERS is returned if no servers are available to test with.
365 MEMCACHED_NOT_SUPPORTED is returned if we were not able to determine
366 if support was available. All other responses then MEMCACHED_SUCCESS
367 report an error of some sort. This behavior also enables
368 MEMCACHED_BEHAVIOR_TCP_NODELAY when set.
369 .UNINDENT
370 .UNINDENT
371 .sp
372 MEMCACHED_BEHAVIOR_KEEPALIVE
373 .INDENT 0.0
374 .INDENT 3.5
375 .sp
376 Enable TCP_KEEPALIVE behavior.
377 .UNINDENT
378 .UNINDENT
379 .sp
380 MEMCACHED_BEHAVIOR_KEEPALIVE_IDLE
381 .INDENT 0.0
382 .INDENT 3.5
383 .sp
384 Specify time, in seconds, to mark a connection as idle. This is only available as an option Linux.
385 .UNINDENT
386 .UNINDENT
387 .sp
388 MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
389 .INDENT 0.0
390 .INDENT 3.5
391 .sp
392 Find the current size of SO_SNDBUF. A value of 0 means either an error
393 occured or no hosts were available. It is safe to assume system default
394 if this occurs. If an error occurs you can checked the last cached errno statement to find the specific error.
395 .UNINDENT
396 .UNINDENT
397 .sp
398 MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
399 .INDENT 0.0
400 .INDENT 3.5
401 .sp
402 Find the current size of SO_RCVBUF. A value of 0 means either an error
403 occured or no hosts were available. It is safe to assume system default
404 if this occurs. If an error occurs you can checked the last cached errno statement to find the specific error.
405 .UNINDENT
406 .UNINDENT
407 .sp
408 MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
409 .INDENT 0.0
410 .INDENT 3.5
411 .sp
412 This number of times a host can have an error before it is disabled.
413 .UNINDENT
414 .UNINDENT
415 .sp
416 MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS
417 .INDENT 0.0
418 .INDENT 3.5
419 .sp
420 If enabled any hosts which have been flagged as disabled will be removed
421 from the list of servers in the memcached_st structure. This must be used
422 in combination with MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT.
423 .UNINDENT
424 .UNINDENT
425 .sp
426 MEMCACHED_BEHAVIOR_RETRY_TIMEOUT
427 .INDENT 0.0
428 .INDENT 3.5
429 .sp
430 When enabled a host which is problematic will only be checked for usage
431 based on the amount of time set by this behavior.
432 .UNINDENT
433 .UNINDENT
434 .sp
435 MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY
436 .INDENT 0.0
437 .INDENT 3.5
438 .sp
439 When enabled the prefix key will be added to the key when determining
440 server by hash.
441 .UNINDENT
442 .UNINDENT
443 .SH RETURN
444 .sp
445 memcached_behavior_get() returns either the current value of the get, or 0
446 or 1 on simple flag behaviors (1 being enabled). memcached_behavior_set()
447 returns failure or success.
448 .SH NOTES
449 .sp
450 memcached_behavior_set() in version .17 was changed from taking a pointer
451 to data value, to taking a uin64_t.
452 .SH HOME
453 .sp
454 To find out more information please check:
455 \fI\%https://launchpad.net/libmemcached\fP
456 .SH AUTHOR
457 .sp
458 Brian Aker, <\fI\%brian@tangent.org\fP>
459 .SH SEE ALSO
460 .sp
461 memcached(1) libmemcached(3) memcached_strerror(3)
462 .SH AUTHOR
463 Brian Aker
464 .SH COPYRIGHT
465 2011, Brian Aker
466 .\" Generated by docutils manpage writer.
467 .\"
468 .