1MEMCACHED_BEHAVIOR_SET(3)        libmemcached        MEMCACHED_BEHAVIOR_SET(3)
2
3
4

NAME

6       memcached_behavior_set - libmemcached Documentation
7
8       Manipulate the behavior of a memcached_st structure.
9

SYNOPSIS

11       #include <libmemcached/memcached.h>
12
13       memcached_behavior_t
14
15       uint64_t                      memcached_behavior_get(memcached_st *ptr,
16       memcached_behavior_t flag)
17
18       memcached_return_t            memcached_behavior_set(memcached_st *ptr,
19       memcached_behavior_t flag, uint64_t data)
20
21       Compile and link with -lmemcached
22

DESCRIPTION

24       libmemcached(3)     behavior     can     be     modified    by    using
25       memcached_behavior_set(). Default behavior is the library strives to be
26       quick  and accurate. Some behavior, while being faster, can also result
27       in not entirely accurate behavior (for instance,  memcached_set()  will
28       always respond with MEMCACHED_SUCCESS).
29
30       memcached_behavior_get()  takes  a behavior flag and returns whether or
31       not that behavior is currently enabled in the client.
32
33       memcached_behavior_set() changes the value of a  particular  option  of
34       the client. It takes both a flag (listed below) and a value. For simple
35       on or 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       MEMCACHED_BEHAVIOR_USE_UDP
39
40       Causes libmemcached(3) to use the UDP transport when communicating with
41       a memcached server. Not all I/O operations are testsed when this behav‐
42       ior   is   enababled.   The   following  operations  will  return  MEM‐
43       CACHED_NOT_SUPPORTED when executed with the  MEMCACHED_BEHAVIOR_USE_UDP
44       enabled:  memcached_version(),  memcached_stat(), memcached_get(), mem‐
45       cached_get_by_key(),  memcached_mget(),  memcached_mget_by_key(),  mem‐
46       cached_fetch(), memcached_fetch_result(), memcached_fetch_execute().
47
48       All  other  operations are testsed but are executed in a 'fire-and-for‐
49       get' mode, in which once the client  has  executed  the  operation,  no
50       attempt  will  be  made  to  ensure the operation has been received and
51       acted on by the server.
52
53       libmemcached(3) does not allow TCP and UDP servers to be shared  within
54       the  same  libmemached(3)  client  'instance'.  An attempt to add a TCP
55       server  when  this  behavior  is  enabled  will  result   in   a   MEM‐
56       CACHED_INVALID_HOST_PROTOCOL,  as  will  attempting to add a UDP server
57       when this behavior has not been enabled.
58
59       MEMCACHED_BEHAVIOR_NO_BLOCK
60
61       Causes libmemcached(3) to use  asychronous  IO.  This  is  the  fastest
62       transport available for storage functions.
63
64       MEMCACHED_BEHAVIOR_SND_TIMEOUT
65
66       This  sets  the  microsecond behavior of the socket against the SO_SND‐
67       TIMEO flag.  In cases where you cannot use non-blocking  IO  this  will
68       allow you to still have timeouts on the sending of data.
69
70       MEMCACHED_BEHAVIOR_RCV_TIMEOUT
71
72       This  sets  the  microsecond behavior of the socket against the SO_RCV‐
73       TIMEO flag.
74
75       In cases where you cannot use non-blocking IO this will  allow  you  to
76       still have timeouts on the reading of data.
77
78       MEMCACHED_BEHAVIOR_TCP_NODELAY
79
80       Turns  on the no-delay feature for connecting sockets (may be faster in
81       some environments).
82
83       MEMCACHED_BEHAVIOR_HASH
84
85       Makes the default hashing algorithm for keys use MD5. The value can  be
86       set   to   either   MEMCACHED_HASH_DEFAULT,   MEMCACHED_HASH_MD5,  MEM‐
87       CACHED_HASH_CRC, MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64,  MEM‐
88       CACHED_HASH_FNV1_32,  MEMCACHED_HASH_FNV1A_32,  MEMCACHED_HASH_JENKINS,
89       MEMCACHED_HASH_HSIEH, and MEMCACHED_HASH_MURMUR.
90
91       Each hash has it's advantages and it's weaknesses. If you don't know or
92       don't care, just go with the default.
93
94       Support  for MEMCACHED_HASH_HSIEH is a compile time option that is dis‐
95       abled by default. To enable tests for this hashing algorithm, configure
96       and build libmemcached with the --enable-hash_hsieh.
97
98       MEMCACHED_BEHAVIOR_DISTRIBUTION
99
100       Using  this  you  can  enable different means of distributing values to
101       servers.
102
103       The default method is  MEMCACHED_DISTRIBUTION_MODULA.  You  can  enable
104       consistent  hashing by setting MEMCACHED_DISTRIBUTION_CONSISTENT.  Con‐
105       sistent hashing delivers better distribution and allows servers  to  be
106       added  to  the  cluster  with  minimal  cache  losses.  Currently  MEM‐
107       CACHED_DISTRIBUTION_CONSISTENT is an alias for the value MEMCACHED_DIS‐
108       TRIBUTION_CONSISTENT_KETAMA.
109
110       MEMCACHED_BEHAVIOR_CACHE_LOOKUPS
111
112       Deprecated  since  version  0.46(?):  DNS lookups are now always cached
113       until an error occurs with the server.
114
115       Memcached can cache named lookups so that DNS  lookups  are  made  only
116       once.
117
118
119       MEMCACHED_BEHAVIOR_SUPPORT_CAS
120
121       Support CAS operations (this is not enabled by default at this point in
122       the server since it imposes a slight performance penalty).
123
124       MEMCACHED_BEHAVIOR_KETAMA
125
126       Sets  the  default   distribution   to   MEMCACHED_DISTRIBUTION_CONSIS‐
127       TENT_KETAMA and the hash to MEMCACHED_HASH_MD5.
128
129       MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED
130              Sets  the default distribution to MEMCACHED_DISTRIBUTION_CONSIS‐
131              TENT_KETAMA with the weighted  tests.   and  the  hash  to  MEM‐
132              CACHED_HASH_MD5.
133
134       MEMCACHED_BEHAVIOR_KETAMA_HASH
135
136       Sets the hashing algorithm for host mapping on continuum. The value can
137       be  set  to  either  MEMCACHED_HASH_DEFAULT,  MEMCACHED_HASH_MD5,  MEM‐
138       CACHED_HASH_CRC,  MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64, MEM‐
139       CACHED_HASH_FNV1_32, and MEMCACHED_HASH_FNV1A_32.
140
141       MEMCACHED_BEHAVIOR_KETAMA_COMPAT
142
143       Sets the compatibility mode. The  value  can  be  set  to  either  MEM‐
144       CACHED_KETAMA_COMPAT_LIBMEMCACHED   (this   is  the  default)  or  MEM‐
145       CACHED_KETAMA_COMPAT_SPY to be compatible with the SPY Memcached client
146       for Java.
147
148       MEMCACHED_BEHAVIOR_POLL_TIMEOUT
149
150       Modify the timeout value that is used by poll. The default value is -1.
151       An signed int must be passed to memcached_behavior_set to  change  this
152       value  (this requires casting). For memcached_behavior_get a signed int
153       value will be cast and returned as the unsigned long long.
154
155       MEMCACHED_BEHAVIOR_USER_DATA
156
157       Deprecated since version <: 0.30
158
159       MEMCACHED_BEHAVIOR_BUFFER_REQUESTS
160
161       Enabling buffered IO causes commands to "buffer" instead of being sent.
162       Any  action  that  gets  data  causes  this buffer to be be sent to the
163       remote connection. Quiting the connection or closing down  the  connec‐
164       tion  will also cause the buffered data to be pushed to the remote con‐
165       nection.
166
167       MEMCACHED_BEHAVIOR_VERIFY_KEY
168
169       Enabling this will cause libmemcached(3) to test  all  keys  to  verify
170       that they are valid keys.
171
172       MEMCACHED_BEHAVIOR_SORT_HOSTS
173
174       Enabling  this will cause hosts that are added to be placed in the host
175       list in sorted order. This will defeat consisten hashing.
176
177       MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT
178
179       In non-blocking mode this changes  the  value  of  the  timeout  during
180       socket  connection  in  milliseconds.  Specifying  -1 means an infinite
181       time‐out.
182
183       MEMCACHED_BEHAVIOR_BINARY_PROTOCOL
184
185       Enable the use of the binary protocol. Please note that you cannot tog‐
186       gle this flag on an open connection.
187
188       MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
189
190       Set  this  value  to enable the server be removed after continuous MEM‐
191       CACHED_BEHAVIOR_SERVER_FAILURE_LIMIT times connection failure.
192
193       MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK
194
195       Set this value to tune the number of messages that may be  sent  before
196       libmemcached  should start to automatically drain the input queue. Set‐
197       ting this value to high, may cause libmemcached to deadlock (trying  to
198       send data, but the send will block because the input buffer in the ker‐
199       nel is full).
200
201       MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK
202
203       Set this value to tune the number of bytes that may be sent before lib‐
204       memcached  should start to automatically drain the input queue (need at
205       least 10 IO requests sent without reading the  input  buffer).  Setting
206       this  value to high, may cause libmemcached to deadlock (trying to send
207       data, but the send will block because the input buffer in the kernel is
208       full).
209
210       MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH
211
212       The  binary protocol works a bit different than the textual protocol in
213       that a multiget is implemented as a pipe of single get-operations which
214       are  sent  to  the  server in a chunk. If you are using large multigets
215       from your application, you may improve the latency of the gets by  set‐
216       ting  this  value  so you send out the first chunk of requests when you
217       hit the specified limit.  It allows the servers to start processing the
218       requests  to send the data back while the rest of the requests are cre‐
219       ated and sent to the server.
220
221       MEMCACHED_BEHAVIOR_NOREPLY
222
223       Set this value to specify that you really don't care about  the  result
224       from your storage commands (set, add, replace, append, prepend).
225
226       MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS
227
228       If  you  just  want  "a  poor  mans HA", you may specify the numbers of
229       replicas libmemcached should store of each item (on different servers).
230       This  replication  does not dedicate certain memcached servers to store
231       the replicas in, but instead it will store the replicas  together  with
232       all  of  the  other  objects (on the 'n' next servers specified in your
233       server list).
234
235       MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ
236
237       Allows randomizing the replica reads starting point. Normally the  read
238       is  done  from primary server and in case of miss the read is done from
239       primary + 1, then primary + 2 all the way  to  'n'  replicas.  If  this
240       option  is set on the starting point of the replica reads is randomized
241       between the servers.  This allows distributing read  load  to  multiple
242       servers with the expense of more write traffic.
243
244       MEMCACHED_BEHAVIOR_CORK
245
246       This  open  has  been  deprecated  with the behavior now built and used
247       appropriately on selected platforms.
248
249       MEMCACHED_BEHAVIOR_KEEPALIVE
250
251       Enable TCP_KEEPALIVE behavior.
252
253       MEMCACHED_BEHAVIOR_KEEPALIVE_IDLE
254
255       Specify time, in seconds, to mark a connection as idle.  This  is  only
256       available as an option Linux.
257
258       MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
259
260       Find  the current size of SO_SNDBUF. A value of 0 means either an error
261       occured or no hosts were available. It is safe to assume system default
262       if  this  occurs.  If  an  error occurs you can checked the last cached
263       errno statement to find the specific error.
264
265       MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
266
267       Find the current size of SO_RCVBUF. A value of 0 means either an  error
268       occured or no hosts were available. It is safe to assume system default
269       if this occurs. If an error occurs you  can  checked  the  last  cached
270       errno statement to find the specific error.
271
272       MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
273
274       Deprecated           since          version          0.48:          See
275       MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS
276
277       This number of times a host can have an error before it is disabled.
278
279
280       MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS
281
282       Deprecated          since          version          0.48:           See
283       MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS
284
285       If  enabled  any  hosts  which  have  been  flagged as disabled will be
286       removed from the list of servers in the  memcached_st  structure.  This
287       must   be  used  in  combination  with  MEMCACHED_BEHAVIOR_SERVER_FAIL‐
288       URE_LIMIT.
289
290
291       MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS
292              If enabled any hosts which have been flagged as disabled will be
293              removed from the list of servers in the memcached_st structure.
294
295       MEMCACHED_BEHAVIOR_RETRY_TIMEOUT
296
297       When enabled a host which is problematic will only be checked for usage
298       based on the amount of time set by this behavior. The value is in  sec‐
299       onds.
300
301       MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY
302
303       When  enabled  the prefix key will be added to the key when determining
304       server by hash. See MEMCACHED_CALLBACK_NAMESPACE for additional  infor‐
305       mation.
306

RETURN

308       memcached_behavior_get  returns either the current value of the get, or
309       0 or 1 on simple flag behaviors  (1  being  enabled).  memcached_behav‐
310       ior_set returns failure or success.
311

NOTES

313       memcached_behavior_set in version .17 was changed from taking a pointer
314       to data value, to taking a uin64_t.
315

HOME

317       To find out more information please check: http://libmemcached.org/
318

SEE ALSO

320       memcached(1) libmemcached(3) memcached_strerror(3)
321

AUTHOR

323       Brian Aker
324
326       2011-2013, Brian Aker DataDifferential, http://datadifferential.com/
327
328
329
330
3311.0.18                         February 09, 2014     MEMCACHED_BEHAVIOR_SET(3)
Impressum