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_USE_UDP
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().
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
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.
60
=item MEMCACHED_BEHAVIOR_NO_BLOCK
62
Causes libmemcached(3) to use asychronous IO. This is the fastest transport
63
available for storage functions. For read operations it is currently
64
similar in performance to the non-blocking method (this is being
67
=item MEMCACHED_BEHAVIOR_SND_TIMEOUT
69
This sets the microsecond behavior of the socket against the SO_SNDTIMEO flag.
70
In cases where you cannot use non-blocking IO this will allow you to still have
71
timeouts on the sending of data.
73
=item MEMCACHED_BEHAVIOR_RCV_TIMEOUT
75
This sets the microsecond behavior of the socket against the SO_RCVTIMEO flag.
76
In cases where you cannot use non-blocking IO this will allow you to still have
77
timeouts on the reading of data.
79
=item MEMCACHED_BEHAVIOR_TCP_NODELAY
81
Turns on the no-delay feature for connecting sockets (may be faster in some
84
=item MEMCACHED_BEHAVIOR_HASH
86
Makes the default hashing algorithm for keys use MD5. The value can be set
87
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.
88
Each hash has it's advantages and it's weaknesses. If you dont know or dont care, just go with the default.
90
=item MEMCACHED_BEHAVIOR_DISTRIBUTION
92
Using this you can enable different means of distributing values to servers.
93
The default method is MEMCACHED_DISTRIBUTION_MODULA. You can enable
94
consistent hashing by setting MEMCACHED_DISTRIBUTION_CONSISTENT.
95
Consistent hashing delivers better distribution and allows servers to be
96
added to the cluster with minimal cache losses. Currently
97
MEMCACHED_DISTRIBUTION_CONSISTENT is an alias for the value
98
MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA.
100
=item MEMCACHED_BEHAVIOR_CACHE_LOOKUPS
102
Memcached can cache named lookups so that DNS lookups are made only once.
104
=item MEMCACHED_BEHAVIOR_SUPPORT_CAS
106
Support CAS operations (this is not enabled by default at this point in the server since it imposes a slight performance penalty).
108
=item MEMCACHED_BEHAVIOR_KETAMA
110
Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA
111
and the hash to MEMCACHED_HASH_MD5.
113
=item MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED
115
Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA with the weighted support.
116
and the hash to MEMCACHED_HASH_MD5.
118
=item MEMCACHED_BEHAVIOR_KETAMA_HASH
120
Sets the hashing algorithm for host mapping on continuum. The value can be set
121
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.
123
=item MEMCACHED_BEHAVIOR_POLL_TIMEOUT
125
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.
127
=item MEMCACHED_BEHAVIOR_USER_DATA
129
This allows you to store a pointer to a specifc piece of data. This can be
130
retrieved from inside of memcached_fetch_execute(). Cloning a memcached_st
132
will copy the pointer to the clone. This was deprecated in 0.14 in favor
133
of memcached_callback_set(3). This will be removed in 0.15.
135
=item MEMCACHED_BEHAVIOR_BUFFER_REQUESTS
137
Enabling buffered IO causes commands to "buffer" instead of being sent. Any
138
action that gets data causes this buffer to be be sent to the remote
139
connection. Quiting the connection or closing down the connection will also
140
cause the buffered data to be pushed to the remote connection.
142
=item MEMCACHED_BEHAVIOR_VERIFY_KEY
144
Enabling this will cause libmemcached(3) to test all keys to verify that they
147
=item MEMCACHED_BEHAVIOR_SORT_HOSTS
149
Enabling this will cause hosts that are added to be placed in the host list in
150
sorted order. This will defeat consisten hashing.
152
=item MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT
154
In non-blocking mode this changes the value of the timeout during socket
157
=item MEMCACHED_BEHAVIOR_BINARY_PROTOCOL
159
Enable the use of the binary protocol. Please note that you cannot toggle
160
this flag on an open connection.
162
=item MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
164
Set this value to enable the server be removed after continuous MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
165
times connection failure.
167
=item MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK
169
Set this value to tune the number of messages that may be sent before
170
libmemcached should start to automatically drain the input queue. Setting
171
this value to high, may cause libmemcached to deadlock (trying to send data,
172
but the send will block because the input buffer in the kernel is full).
174
=item MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK
176
Set this value to tune the number of bytes that may be sent before
177
libmemcached should start to automatically drain the input queue (need
178
at least 10 IO requests sent without reading the input buffer). Setting
179
this value to high, may cause libmemcached to deadlock (trying to send
180
data, but the send will block because the input buffer in the kernel is full).
182
=item MEMCACHED_BEHAVIOR_NOREPLY
184
Set this value to specify that you really don't care about the result
185
from your storage commands (set, add, replace, append, prepend).
191
memcached_behavior_get() returns either the current value of the get, or 0
192
or 1 on simple flag behaviors (1 being enabled). memcached_behavior_set()
193
returns failure or success.
197
memcached_behavior_set() in version .17 was changed from taking a pointer
198
to data value, to taking a uin64_t.
202
To find out more information please check:
203
L<http://tangent.org/552/libmemcached.html>
207
Brian Aker, E<lt>brian@tangent.orgE<gt>
211
memcached(1) libmemcached(3) memcached_strerror(3)