1 .TH "MEMCACHED_BEHAVIOR" "3" "April 09, 2011" "0.47" "libmemcached"
3 memcached_behavior \- libmemcached Documentation
5 .nr rst2man-indent-level 0
9 level \\n[rst2man-indent-level]
10 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
17 .\" .rstReportMargin pre:
19 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
20 . nr rst2man-indent-level +1
21 .\" .rstReportMargin post:
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
31 .\" Man page generated from reStructeredText.
37 C Client Library for memcached (libmemcached, \-lmemcached)
42 #include <libmemcached/memcached.h>
45 memcached_behavior_get (memcached_st *ptr,
46 memcached_behavior flag);
49 memcached_behavior_set (memcached_st *ptr,
50 memcached_behavior flag,
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).
62 memcached_behavior_get() takes a behavior flag and returns whether or not
63 that behavior is currently enabled in the client.
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.
70 MEMCACHED_BEHAVIOR_USE_UDP
74 Causes libmemcached(3) to use the UDP transport when communicating
75 with a memcached server. Not all I/O operations are testsed
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().
82 All other operations are testsed 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
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.
94 MEMCACHED_BEHAVIOR_NO_BLOCK
98 Causes libmemcached(3) to use asychronous IO. This is the fastest transport
99 available for storage functions.
103 MEMCACHED_BEHAVIOR_SND_TIMEOUT
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.
113 MEMCACHED_BEHAVIOR_RCV_TIMEOUT
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.
123 MEMCACHED_BEHAVIOR_TCP_NODELAY
127 Turns on the no\-delay feature for connecting sockets (may be faster in some
132 MEMCACHED_BEHAVIOR_HASH
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 tests for this hashing algorithm, configure and build libmemcached with the \-\-enable\-hash_hsieh.
143 MEMCACHED_BEHAVIOR_DISTRIBUTION
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.
157 MEMCACHED_BEHAVIOR_CACHE_LOOKUPS
161 Memcached can cache named lookups so that DNS lookups are made only once.
165 MEMCACHED_BEHAVIOR_SUPPORT_CAS
169 Support CAS operations (this is not enabled by default at this point in the server since it imposes a slight performance penalty).
173 MEMCACHED_BEHAVIOR_KETAMA
177 Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA
178 and the hash to MEMCACHED_HASH_MD5.
182 MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED
186 Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA with the weighted tests.
187 and the hash to MEMCACHED_HASH_MD5.
191 MEMCACHED_BEHAVIOR_KETAMA_HASH
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.
200 MEMCACHED_BEHAVIOR_KETAMA_COMPAT
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
211 MEMCACHED_BEHAVIOR_POLL_TIMEOUT
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.
219 MEMCACHED_BEHAVIOR_USER_DATA
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
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.
231 MEMCACHED_BEHAVIOR_BUFFER_REQUESTS
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.
242 MEMCACHED_BEHAVIOR_VERIFY_KEY
246 Enabling this will cause libmemcached(3) to test all keys to verify that they
251 MEMCACHED_BEHAVIOR_SORT_HOSTS
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.
260 MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT
264 In non\-blocking mode this changes the value of the timeout during socket
269 MEMCACHED_BEHAVIOR_BINARY_PROTOCOL
273 Enable the use of the binary protocol. Please note that you cannot toggle
274 this flag on an open connection.
278 MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
282 Set this value to enable the server be removed after continuous MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
283 times connection failure.
287 MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK
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).
298 MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK
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).
310 MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH
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
325 MEMCACHED_BEHAVIOR_NOREPLY
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).
334 MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS
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).
346 MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ
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
359 MEMCACHED_BEHAVIOR_CORK
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 tests 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.
372 MEMCACHED_BEHAVIOR_KEEPALIVE
376 Enable TCP_KEEPALIVE behavior.
380 MEMCACHED_BEHAVIOR_KEEPALIVE_IDLE
384 Specify time, in seconds, to mark a connection as idle. This is only available as an option Linux.
388 MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
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.
398 MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
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.
408 MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
412 This number of times a host can have an error before it is disabled.
416 MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS
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.
426 MEMCACHED_BEHAVIOR_RETRY_TIMEOUT
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.
435 MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY
439 When enabled the prefix key will be added to the key when determining
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.
450 memcached_behavior_set() in version .17 was changed from taking a pointer
451 to data value, to taking a uin64_t.
454 To find out more information please check:
455 \fI\%https://launchpad.net/libmemcached\fP
458 Brian Aker, <\fI\%brian@tangent.org\fP>
461 \fImemcached(1)\fP \fIlibmemcached(3)\fP \fImemcached_strerror(3)\fP
465 2011, Brian Aker DataDifferential, http://datadifferential.com/
466 .\" Generated by docutils manpage writer.