1 libmemcached Configuration
2 ==========================
7 #include <libmemcached-|libmemcached_version|/memcached.h>
8 Compile and link with -lmemcached
10 .. function:: memcached_st *memcached(const char *string, size_t string_length)
12 :param string: configuration string
13 :param string_length: length of the configuration string without any terminating zero
14 :returns: allocated and initialized `memcached_st` struct
16 .. function:: memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, char *error_buffer, size_t error_buffer_size)
18 :param option_string: configuration string
19 :param length: length of the configuration string without any terminating zero
20 :param error_buffer: buffer used to store any error message
21 :param error_buffer_size: available size of the `error_buffer`
22 :returns: `memcached_return_t` indicating success
27 `libmemcached` implements a custom language for configuring and modifying
28 servers. By passing in an option string you can generate a `memcached_st` object
29 that you can use in your application directly.
34 .. describe:: --SERVER=<servername>:<optional_port>/?<optional_weight>
36 Provide a servername to be used by the client.
38 Providing a weight will cause weighting to occur with all hosts with each
39 server getting a default weight of 1.
41 .. describe:: --SOCKET=\"<filepath>/?<optional_weight>\"
43 Provide a filepath to a UNIX socket file. Providing a weight will cause
44 weighting to occur with all hosts with each server getting a default weight
47 .. describe:: --VERIFY-KEY
49 Verify that keys that are being used fit within the design of the protocol
52 .. describe:: --REMOVE_FAILED_SERVERS
54 Enable the behavior `MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS`.
56 .. describe:: --BINARY-PROTOCOL
58 Force all connections to use the binary protocol.
60 .. describe:: --BUFFER-REQUESTS
62 Please see `MEMCACHED_BEHAVIOR_BUFFER_REQUESTS`.
64 .. describe:: --CONFIGURE-FILE=
66 Provide a configuration file to be used to load requests. Beware that by
67 using a configuration file `libmemcached` will reset `memcached_st` based
68 on information only contained in the file.
70 .. describe:: --CONNECT-TIMEOUT=
72 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT`.
74 .. describe:: --DISTRIBUTION=
76 Set the distribution model used by the client.
77 See `memcached_behavior_set` for more details.
81 Set the hashing algorithm used for placing keys on servers.
83 .. describe:: --HASH-WITH-NAMESPACE
85 When enabled the prefix key will be added to the key when determining which
86 server to store the data in.
88 .. describe:: --NOREPLY
90 Enable "no reply" for all calls that support this. It is highly recommended
91 that you use this option with the binary protocol only.
93 .. describe:: --NUMBER-OF-REPLICAS=
95 Set the number of servers that keys will be replicated to.
97 .. describe:: --RANDOMIZE-REPLICA-READ
99 Select randomly the server within the replication pool to read from.
101 .. describe:: --SORT-HOSTS
103 When adding new servers always calculate their distribution based on sorted
106 .. describe:: --SUPPORT-CAS
108 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_SUPPORT_CAS`
110 .. describe:: --USE-UDP
112 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_USE_UDP`
114 .. describe:: --NAMESPACE=
116 A namespace is a container that provides context for keys, only other
117 requests that know the namespace can access these values. This is
118 accomplished by prepending the namespace value to all keys.
120 Memcached Pool Options:
121 ~~~~~~~~~~~~~~~~~~~~~~~
123 .. describe:: --POOL-MIN
125 Initial size of pool.
127 .. describe:: --POOL-MAX
129 Maximize size of the pool.
134 .. describe:: --TCP-NODELAY
136 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_TCP_NODELAY`
138 .. describe:: --TCP-KEEPALIVE
140 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_TCP_KEEPALIVE`
142 .. describe:: --RETRY-TIMEOUT=
144 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_RETRY_TIMEOUT`
146 .. describe:: --SERVER-FAILURE-LIMIT=
148 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT`
150 .. describe:: --SND-TIMEOUT=
152 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_SND_TIMEOUT`
154 .. describe:: --SOCKET-RECV-SIZE=
156 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE`
158 .. describe:: --SOCKET-SEND-SIZE=
160 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE`
162 .. describe:: --POLL-TIMEOUT=
164 Set the timeout used by :manpage:`poll(3)`.
166 .. describe:: --IO-BYTES-WATERMARK=
168 .. describe:: --IO-KEY-PREFETCH=
170 .. describe:: --IO-MSG-WATERMARK=
172 .. describe:: --TCP-KEEPIDLE
174 .. describe:: --RCV-TIMEOUT=
179 .. describe:: INCLUDE
181 Include a file in configuration.
182 Unlike ``--CONFIGURE-FILE=`` this will not reset `memcached_st`.
186 Reset `memcached_st` and continue to process.
190 End configuration processing.
194 End configuration processing and throw an error.
199 .. envvar:: LIBMEMCACHED
204 `memcached` returns a pointer to the `memcached_st` that was created (or
205 initialized). On an allocation failure, it returns NULL.
212 const char *config_string=
213 "--SERVER=host10.example.com "
214 "--SERVER=host11.example.com "
215 "--SERVER=host10.example.com";
216 memcached_st *memc= memcached(config_string, strlen(config_string));
220 memcached_free(memc);
227 :manpage:`memcached(1)`
228 :manpage:`libmemcached(3)`
229 :manpage:`memcached_strerror(3)`
233 * :manpage:`memcached(1)`
234 * :doc:`../libmemcached`
235 * :doc:`memcached_strerror`