blib/lib/Memcached/libmemcached/memcached_behavior.pm

filter: Statementstmt 100% 1 / 1 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 1 / 1 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Memcached/libmemcached/memcached_auto.pm ↑ Summary blib/lib/Memcached/libmemcached/memcached_callback.pm »
1 package Memcached::libmemcached::memcached_behavior;
2  
3 =head1 NAME
4  
5 memcached_behavior_get, memcached_behavior_set - Manipulate behavior
6  
7 =head1 LIBRARY
8  
9 C Client Library for memcached (libmemcached, -lmemcached)
10  
11 =head1 SYNOPSIS
12  
13 #include <memcached.h>
14  
15 uint64_t
16 memcached_behavior_get (memcached_st *ptr,
17 memcached_behavior flag);
18  
19 memcached_return_t
20 memcached_behavior_set (memcached_st *ptr,
21 memcached_behavior flag,
22 uint64_t data);
23  
24 =head1 DESCRIPTION
25  
26 libmemcached(3) behavior can be modified by use memcached_behavior_set().
27 Default behavior is the library strives to be quick and accurate. Some
28 behavior, while being faster, can also result in not entirely accurate
29 behavior (for instance, memcached_set() will always respond with
30 C<MEMCACHED_SUCCESS>).
31  
32 memcached_behavior_get() takes a behavior flag and returns whether or not
33 that behavior is currently enabled in the client.
34  
35 memcached_behavior_set() changes the value of a particular option of the
36 client. It takes both a flag (listed below) and a value. For simple on or
37 off options you just need to pass in a value of 1. Calls to
38 memcached_behavior_set() will flush and reset all connections.
39  
40 =over 4
41  
42 =item MEMCACHED_BEHAVIOR_USE_UDP
43  
44 Causes libmemcached(3) to use the UDP transport when communicating
45 with a memcached server. Not all I/O operations are supported
46 when this behavior is enababled. The following operations will return
47 C<MEMCACHED_NOT_SUPPORTED> when executed with the MEMCACHED_BEHAVIOR_USE_UDP
48 enabled: memcached_version(), memcached_stat(), memcached_get(),
49 memcached_get_by_key(), memcached_mget(), memcached_mget_by_key(),
50 memcached_fetch(), memcached_fetch_result(), memcached_value_fetch().
51  
52 All other operations are supported but are executed in a 'fire-and-forget'
53 mode, in which once the client has executed the operation, no attempt
54 will be made to ensure the operation has been received and acted on by the
55 server.
56  
57 libmemcached(3) does not allow TCP and UDP servers to be shared within
58 the same libmemached(3) client 'instance'. An attempt to add a TCP server
59 when this behavior is enabled will result in a C<MEMCACHED_INVALID_HOST_PROTOCOL>,
60 as will attempting to add a UDP server when this behavior has not been enabled.
61  
62 =item MEMCACHED_BEHAVIOR_NO_BLOCK
63  
64 Causes libmemcached(3) to use asychronous IO. This is the fastest transport
65 available for storage functions.
66  
67 =item MEMCACHED_BEHAVIOR_SND_TIMEOUT
68  
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.
72  
73 =item MEMCACHED_BEHAVIOR_RCV_TIMEOUT
74  
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.
78  
79 =item MEMCACHED_BEHAVIOR_TCP_NODELAY
80  
81 Turns on the no-delay feature for connecting sockets (may be faster in some
82 environments).
83  
84 =item MEMCACHED_BEHAVIOR_HASH
85  
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 don't know or don't care, just go with the default.
89 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.
90  
91 =item MEMCACHED_BEHAVIOR_DISTRIBUTION
92  
93 Using this you can enable different means of distributing values to servers.
94 The default method is MEMCACHED_DISTRIBUTION_MODULA. You can enable
95 consistent hashing by setting MEMCACHED_DISTRIBUTION_CONSISTENT.
96 Consistent hashing delivers better distribution and allows servers to be
97 added to the cluster with minimal cache losses. Currently
98 MEMCACHED_DISTRIBUTION_CONSISTENT is an alias for the value
99 MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA.
100  
101 =item MEMCACHED_BEHAVIOR_CACHE_LOOKUPS
102  
103 Memcached can cache named lookups so that DNS lookups are made only once.
104  
105 =item MEMCACHED_BEHAVIOR_SUPPORT_CAS
106  
107 Support CAS operations (this is not enabled by default at this point in the server since it imposes a slight performance penalty).
108  
109 =item MEMCACHED_BEHAVIOR_KETAMA
110  
111 Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA
112 and the hash to MEMCACHED_HASH_MD5.
113  
114 =item MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED
115  
116 Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA with the weighted support.
117 and the hash to MEMCACHED_HASH_MD5.
118  
119 =item MEMCACHED_BEHAVIOR_KETAMA_HASH
120  
121 Sets the hashing algorithm for host mapping on continuum. The value can be set
122 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  
124 =item MEMCACHED_BEHAVIOR_KETAMA_COMPAT
125  
126 Sets the compatibility mode. The value can be set to either
127 MEMCACHED_KETAMA_COMPAT_LIBMEMCACHED (this is the default) or
128 MEMCACHED_KETAMA_COMPAT_SPY to be compatible with the SPY Memcached client
129 for Java.
130  
131 =item MEMCACHED_BEHAVIOR_POLL_TIMEOUT
132  
133 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.
134  
135 =item MEMCACHED_BEHAVIOR_USER_DATA
136  
137 This allows you to store a pointer to a specifc piece of data. This can be
138 retrieved from inside of memcached_fetch_execute(). Cloning a memcached_st
139  
140 will copy the pointer to the clone. This was deprecated in 0.14 in favor
141 of memcached_callback_set(3). This will be removed in 0.15.
142  
143 =item MEMCACHED_BEHAVIOR_BUFFER_REQUESTS
144  
145 Enabling buffered IO causes commands to "buffer" instead of being sent. Any
146 action that gets data causes this buffer to be be sent to the remote
147 connection. Quiting the connection or closing down the connection will also
148 cause the buffered data to be pushed to the remote connection.
149  
150 =item MEMCACHED_BEHAVIOR_VERIFY_KEY
151  
152 Enabling this will cause libmemcached(3) to test all keys to verify that they
153 are valid keys.
154  
155 =item MEMCACHED_BEHAVIOR_SORT_HOSTS
156  
157 Enabling this will cause hosts that are added to be placed in the host list in
158 sorted order. This will defeat consisten hashing.
159  
160 =item MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT
161  
162 In non-blocking mode this changes the value of the timeout during socket
163 connection.
164  
165 =item MEMCACHED_BEHAVIOR_BINARY_PROTOCOL
166  
167 Enable the use of the binary protocol. Please note that you cannot toggle
168 this flag on an open connection.
169  
170 =item MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
171  
172 Set this value to enable the server be removed after continuous MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
173 times connection failure.
174  
175 =item MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK
176  
177 Set this value to tune the number of messages that may be sent before
178 libmemcached should start to automatically drain the input queue. Setting
179 this value to high, may cause libmemcached to deadlock (trying to send data,
180 but the send will block because the input buffer in the kernel is full).
181  
182 =item MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK
183  
184 Set this value to tune the number of bytes that may be sent before
185 libmemcached should start to automatically drain the input queue (need
186 at least 10 IO requests sent without reading the input buffer). Setting
187 this value to high, may cause libmemcached to deadlock (trying to send
188 data, but the send will block because the input buffer in the kernel is full).
189  
190 =item MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH
191  
192 The binary protocol works a bit different than the textual protocol in
193 that a multiget is implemented as a pipe of single get-operations which
194 are sent to the server in a chunk. If you are using large multigets from
195 your application, you may improve the latency of the gets by setting
196 this value so you send out the first chunk of requests when you hit the
197 specified limit. It allows the servers to start processing the requests
198 to send the data back while the rest of the requests are created and
199 sent to the server.
200  
201 =item MEMCACHED_BEHAVIOR_NOREPLY
202  
203 Set this value to specify that you really don't care about the result
204 from your storage commands (set, add, replace, append, prepend).
205  
206 =item MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS
207  
208 If you just want "a poor mans HA", you may specify the numbers of
209 replicas libmemcached should store of each item (on different servers).
210 This replication does not dedicate certain memcached servers to store the
211 replicas in, but instead it will store the replicas together with all of the
212 other objects (on the 'n' next servers specified in your server list).
213  
214 =item MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ
215  
216 Allows randomizing the replica reads starting point. Normally the read is
217 done from primary server and in case of miss the read is done from primary
218 + 1, then primary + 2 all the way to 'n' replicas. If this option is set
219 on the starting point of the replica reads is randomized between the servers.
220 This allows distributing read load to multiple servers with the expense of
221 more write traffic.
222  
223 =item MEMCACHED_BEHAVIOR_CORK
224  
225 Enable TCP_CORK behavior. This is only available as an option Linux.
226 MEMCACHED_NO_SERVERS is returned if no servers are available to test with.
227 MEMCACHED_NOT_SUPPORTED is returned if we were not able to determine
228 if support was available. All other responses then MEMCACHED_SUCCESS
229 report an error of some sort. This behavior also enables
230 MEMCACHED_BEHAVIOR_TCP_NODELAY when set.
231  
232 =item MEMCACHED_BEHAVIOR_KEEPALIVE
233  
234 Enable TCP_KEEPALIVE behavior.
235  
236 =item MEMCACHED_BEHAVIOR_KEEPALIVE_IDLE
237  
238 Specify time, in seconds, to mark a connection as idle. This is only available as an option Linux.
239  
240 =item MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
241  
242 Find the current size of SO_SNDBUF. A value of 0 means either an error
243 occured or no hosts were available. It is safe to assume system default
244 if this occurs.
245  
246 =item MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
247  
248 Find the current size of SO_RCVBUF. A value of 0 means either an error
249 occured or no hosts were available. It is safe to assume system default
250 if this occurs.
251  
252 =item MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
253  
254 This number of times a host can have an error before it is disabled.
255  
256 =item MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS
257  
258 If enabled any hosts which have been flagged as disabled will be removed
259 from the list of servers in the memcached_st structure. This must be used
260 in combination with MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT.
261  
262 =item MEMCACHED_BEHAVIOR_RETRY_TIMEOUT
263  
264 When enabled a host which is problematic will only be checked for usage
265 based on the amount of time set by this behavior.
266  
267 =back
268  
269 =head1 RETURN
270  
271 memcached_behavior_get() returns either the current value of the get, or 0
272 or 1 on simple flag behaviors (1 being enabled). memcached_behavior_set()
273 returns failure or success.
274  
275 =head1 NOTES
276  
277 memcached_behavior_set() in version .17 was changed from taking a pointer
278 to data value, to taking a uin64_t.
279  
280 =head1 HOME
281  
282 To find out more information please check:
283 L<https://launchpad.net/libmemcached>
284  
285 =head1 AUTHOR
286  
287 Brian Aker, E<lt>brian@tangent.orgE<gt>
288  
289 =head1 SEE ALSO
290  
291 memcached(1) libmemcached(3) memcached_strerror(3)
292  
293 =cut
294  
295 1 1;
« blib/lib/Memcached/libmemcached/memcached_auto.pm ↑ Summary blib/lib/Memcached/libmemcached/memcached_callback.pm »