1 ========================
2 Configuring Libmemcached
3 ========================
11 #include <libmemcached-1.0/memcached.h>
12 Compile and link with -lmemcached
14 .. c:function:: memcached_st *memcached(const char *string, size_t string_length)
16 .. c:function:: memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, char *error_buffer, size_t error_buffer_size)
23 Libmemcached implements a custom language for configuring and modifying
24 servers. By passing in an option string you can generate a ``memcached_st`` object
25 that you can use in your application directly.
30 .. option:: --SERVER=<servername>:<optional_port>/?<optional_weight>
32 Provide a servername to be used by the client.
34 Providing a weight will cause weighting to occur with all hosts with each server getting a default weight of 1.
36 .. option:: --SOCKET=\"<filepath>/?<optional_weight>\"
38 Provide a filepath to a UNIX socket file. Providing a weight will cause weighting to occur with all hosts with each server getting a default weight of 1.
40 .. option:: --VERIFY-KEY
42 Verify that keys that are being used fit within the design of the protocol being used.
44 .. option:: --REMOVE_FAILED_SERVERS
46 Enable the behavior :c:type:`MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS`.
48 .. option:: --BINARY-PROTOCOL
50 Force all connections to use the binary protocol.
52 .. option:: --BUFFER-REQUESTS
54 Please see :c:type:`MEMCACHED_BEHAVIOR_BUFFER_REQUESTS`.
56 .. option:: --CONFIGURE-FILE=
58 Provide a configuration file to be used to load requests. Beware that by using a configuration file libmemcached will reset memcached_st based on information only contained in the file.
60 .. option:: --CONNECT-TIMEOUT=
62 Please see :c:type:`MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT`.
64 .. option:: --DISTRIBUTION=
66 Set the distribution model used by the client. See :c:func:`memcached_behavior_set` for more details.
70 Set the hashing algorithm used for placing keys on servers.
72 .. option:: --HASH-WITH-NAMESPACE
74 When enabled the prefix key will be added to the key when determining which
75 server to store the data in.
79 Enable "no reply" for all calls that support this. It is highly recommended
80 that you use this option with the binary protocol only.
82 .. option:: --NUMBER-OF-REPLICAS=
84 Set the number of servers that keys will be replicated to.
86 .. option:: --RANDOMIZE-REPLICA-READ
88 Select randomly the server within the replication pool to read from.
90 .. option:: --SORT-HOSTS
92 When adding new servers always calculate their distribution based on sorted naming order.
94 .. option:: --SUPPORT-CAS
96 See :manpage:`memcached_behavior_set(3)` for :c:type:`MEMCACHED_BEHAVIOR_SUPPORT_CAS`
100 See :manpage:`memcached_behavior_set(3)` for :c:type:`MEMCACHED_BEHAVIOR_USE_UDP`
102 .. option:: --NAMESPACE=
104 A namespace is a container that provides context for keys, only other
105 requests that know the namespace can access these values. This is
106 accomplished by prepending the namespace value to all keys.
109 ***********************
110 Memcached Pool Options:
111 ***********************
113 .. option:: --POOL-MIN
115 Initial size of pool.
117 .. option:: --POOL-MAX
119 Maximize size of the pool.
125 .. option:: --TCP-NODELAY
127 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_TCP_NODELAY
129 .. option:: --TCP-KEEPALIVE
131 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_TCP_KEEPALIVE
133 .. option:: --RETRY-TIMEOUT=
135 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_RETRY_TIMEOUT
137 .. option:: --SERVER-FAILURE-LIMIT=
139 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
141 .. option:: --SND-TIMEOUT=
143 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SND_TIMEOUT
145 .. option:: --SOCKET-RECV-SIZE=
147 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
149 .. option:: --SOCKET-SEND-SIZE=
151 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
153 .. option:: --POLL-TIMEOUT=
155 That sets the value of the timeout used by :manpage: `poll()`.
157 .. option:: --IO-BYTES-WATERMARK=
159 .. option:: --IO-KEY-PREFETCH=
161 .. option:: --IO-MSG-WATERMARK=
163 .. option:: --TCP-KEEPIDLE
165 .. option:: --RCV-TIMEOUT=
175 Include a file in configuration. Unlike --CONFIGURE-FILE= this will not reset memcached_st
179 Reset memcached_st and continue to process.
183 End configuration processing.
187 End configuration processing and throw an error.
194 .. envvar:: LIBMEMCACHED
202 :c:func:`memcached()` returns a pointer to the memcached_st that was
203 created (or initialized). On an allocation failure, it returns NULL.
214 const char *config_string=
215 "--SERVER=host10.example.com "
216 "--SERVER=host11.example.com "
217 "--SERVER=host10.example.com";
218 memcached_st *memc= memcached(config_string, strlen(config_string));
222 memcached_free(memc);
232 :manpage:`memcached(1)`
233 :manpage:`libmemcached(3)`
234 :manpage:`memcached_strerror(3)`
238 * :manpage:`memcached(1)`
239 * :doc:`libmemcached`
240 * :doc:`memcached_strerror`