3 memcached_behavior_get memcached_behavior_set
7 C Client Library for memcached (libmemcached, -lmemcached)
11 #include <memcached.h>
14 memcached_behavior_get (memcached_st *ptr,
15 memcached_behavior flag);
18 memcached_behavior_set (memcached_st *ptr,
19 memcached_behavior flag,
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>).
30 memcached_behavior_get() takes a behavior flag and returns whether or not
31 that behavior is currently enabled in the client.
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.
40 =item MEMCACHED_BEHAVIOR_NO_BLOCK
42 Causes libmemcached(3) to use asychronous IO. This is the fastest transport
43 available for storage functions. For read operations it is currently
44 similar in performance to the non-blocking method (this is being
47 =item MEMCACHED_BEHAVIOR_SND_TIMEOUT
49 This sets the microsecond behavior of the socket against the SO_SNDTIMEO flag.
50 In cases where you cannot use non-blocking IO this will allow you to still have
51 timeouts on the sending of data.
53 =item MEMCACHED_BEHAVIOR_RCV_TIMEOUT
55 This sets the microsecond behavior of the socket against the SO_RCVTIMEO flag.
56 In cases where you cannot use non-blocking IO this will allow you to still have
57 timeouts on the reading of data.
59 =item MEMCACHED_BEHAVIOR_TCP_NODELAY
61 Turns on the no-delay feature for connecting sockets (may be faster in some
64 =item MEMCACHED_BEHAVIOR_HASH
66 Makes the default hashing algorithm for keys use MD5. The value can be set
67 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. The behavior for all hashes but MEMCACHED_HASH_DEFAULT is identitical to the Java driver written by Dustin Sallings.
69 =item MEMCACHED_BEHAVIOR_DISTRIBUTION
71 Using this you can enable different means of distributing values to servers.
72 The default method is MEMCACHED_DISTRIBUTION_MODULA. You can enable
73 consistent hashing by setting MEMCACHED_DISTRIBUTION_CONSISTENT.
74 Consistent hashing delivers better distribution and allows servers to be
75 added to the cluster with minimal cache losses. Currently
76 MEMCACHED_DISTRIBUTION_CONSISTENT is an alias for the value
77 MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA.
79 =item MEMCACHED_BEHAVIOR_CACHE_LOOKUPS
81 Memcached can cache named lookups so that DNS lookups are made only once.
83 =item MEMCACHED_BEHAVIOR_SUPPORT_CAS
85 Support CAS operations (this is not enabled by default at this point in the server since it imposes a slight performance penalty).
87 =item MEMCACHED_BEHAVIOR_KETAMA
89 Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA
90 and the hash to MEMCACHED_HASH_MD5.
92 =item MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED
94 Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA with the weighted support.
95 and the hash to MEMCACHED_HASH_MD5.
97 =item MEMCACHED_BEHAVIOR_KETAMA_HASH
99 Sets the hashing algorithm for host mapping on continuum. The value can be set
100 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.
102 =item MEMCACHED_BEHAVIOR_POLL_TIMEOUT
104 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.
106 =item MEMCACHED_BEHAVIOR_USER_DATA
108 This allows you to store a pointer to a specifc piece of data. This can be
109 retrieved from inside of memcached_fetch_execute(). Cloning a memcached_st
111 will copy the pointer to the clone. This was deprecated in 0.14 in favor
112 of memcached_callback_set(3). This will be removed in 0.15.
114 =item MEMCACHED_BEHAVIOR_BUFFER_REQUESTS
116 Enabling buffered IO causes commands to "buffer" instead of being sent. Any
117 action that gets data causes this buffer to be be sent to the remote
118 connection. Quiting the connection or closing down the connection will also
119 cause the buffered data to be pushed to the remote connection.
121 =item MEMCACHED_BEHAVIOR_VERIFY_KEY
123 Enabling this will cause libmemcached(3) to test all keys to verify that they
126 =item MEMCACHED_BEHAVIOR_SORT_HOSTS
128 Enabling this will cause hosts that are added to be placed in the host list in
129 sorted order. This will defeat consisten hashing.
131 =item MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT
133 In non-blocking mode this changes the value of the timeout during socket
136 =item MEMCACHED_BEHAVIOR_BINARY_PROTOCOL
138 Enable the use of the binary protocol. Please note that you cannot toggle
139 this flag on an open connection.
141 =item MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
143 Set this value to enable the server be removed after continuous MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
144 times connection failure.
150 memcached_behavior_get() returns either the current value of the get, or 0
151 or 1 on simple flag behaviors (1 being enabled). memcached_behavior_set()
152 returns failure or success.
156 memcached_behavior_set() in version .17 was changed from taking a pointer
157 to data value, to taking a uin64_t.
161 To find out more information please check:
162 L<http://tangent.org/552/libmemcached.html>
166 Brian Aker, E<lt>brian@tangent.orgE<gt>
170 memcached(1) libmemcached(3) memcached_strerror(3)