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 .. function:: memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, char *error_buffer, size_t error_buffer_size)
17 `libmemcached` implements a custom language for configuring and modifying
18 servers. By passing in an option string you can generate a `memcached_st` object
19 that you can use in your application directly.
24 .. describe:: --SERVER=<servername>:<optional_port>/?<optional_weight>
26 Provide a servername to be used by the client.
28 Providing a weight will cause weighting to occur with all hosts with each
29 server getting a default weight of 1.
31 .. describe:: --SOCKET=\"<filepath>/?<optional_weight>\"
33 Provide a filepath to a UNIX socket file. Providing a weight will cause
34 weighting to occur with all hosts with each server getting a default weight
37 .. describe:: --VERIFY-KEY
39 Verify that keys that are being used fit within the design of the protocol
42 .. describe:: --REMOVE_FAILED_SERVERS
44 Enable the behavior `MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS`.
46 .. describe:: --BINARY-PROTOCOL
48 Force all connections to use the binary protocol.
50 .. describe:: --BUFFER-REQUESTS
52 Please see `MEMCACHED_BEHAVIOR_BUFFER_REQUESTS`.
54 .. describe:: --CONFIGURE-FILE=
56 Provide a configuration file to be used to load requests. Beware that by
57 using a configuration file `libmemcached` will reset `memcached_st` based
58 on information only contained in the file.
60 .. describe:: --CONNECT-TIMEOUT=
62 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT`.
64 .. describe:: --DISTRIBUTION=
66 Set the distribution model used by the client.
67 See `memcached_behavior_set` for more details.
71 Set the hashing algorithm used for placing keys on servers.
73 .. describe:: --HASH-WITH-NAMESPACE
75 When enabled the prefix key will be added to the key when determining which
76 server to store the data in.
78 .. describe:: --NOREPLY
80 Enable "no reply" for all calls that support this. It is highly recommended
81 that you use this option with the binary protocol only.
83 .. describe:: --NUMBER-OF-REPLICAS=
85 Set the number of servers that keys will be replicated to.
87 .. describe:: --RANDOMIZE-REPLICA-READ
89 Select randomly the server within the replication pool to read from.
91 .. describe:: --SORT-HOSTS
93 When adding new servers always calculate their distribution based on sorted
96 .. describe:: --SUPPORT-CAS
98 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_SUPPORT_CAS`
100 .. describe:: --USE-UDP
102 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_USE_UDP`
104 .. describe:: --NAMESPACE=
106 A namespace is a container that provides context for keys, only other
107 requests that know the namespace can access these values. This is
108 accomplished by prepending the namespace value to all keys.
110 Memcached Pool Options:
111 ~~~~~~~~~~~~~~~~~~~~~~~
113 .. describe:: --POOL-MIN
115 Initial size of pool.
117 .. describe:: --POOL-MAX
119 Maximize size of the pool.
124 .. describe:: --TCP-NODELAY
126 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_TCP_NODELAY`
128 .. describe:: --TCP-KEEPALIVE
130 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_TCP_KEEPALIVE`
132 .. describe:: --RETRY-TIMEOUT=
134 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_RETRY_TIMEOUT`
136 .. describe:: --SERVER-FAILURE-LIMIT=
138 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT`
140 .. describe:: --SND-TIMEOUT=
142 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_SND_TIMEOUT`
144 .. describe:: --SOCKET-RECV-SIZE=
146 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE`
148 .. describe:: --SOCKET-SEND-SIZE=
150 See `memcached_behavior_set` for `MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE`
152 .. describe:: --POLL-TIMEOUT=
154 Set the timeout used by :manpage:`poll(3)`.
156 .. describe:: --IO-BYTES-WATERMARK=
158 .. describe:: --IO-KEY-PREFETCH=
160 .. describe:: --IO-MSG-WATERMARK=
162 .. describe:: --TCP-KEEPIDLE
164 .. describe:: --RCV-TIMEOUT=
169 .. describe:: INCLUDE
171 Include a file in configuration.
172 Unlike ``--CONFIGURE-FILE=`` this will not reset `memcached_st`.
176 Reset `memcached_st` and continue to process.
180 End configuration processing.
184 End configuration processing and throw an error.
189 .. envvar:: LIBMEMCACHED
194 `memcached` returns a pointer to the memcached_st that was created (or
195 initialized). On an allocation failure, it returns NULL.
202 const char *config_string=
203 "--SERVER=host10.example.com "
204 "--SERVER=host11.example.com "
205 "--SERVER=host10.example.com";
206 memcached_st *memc= memcached(config_string, strlen(config_string));
210 memcached_free(memc);
217 :manpage:`memcached(1)`
218 :manpage:`libmemcached(3)`
219 :manpage:`memcached_strerror(3)`
223 * :manpage:`memcached(1)`
224 * :doc:`../libmemcached`
225 * :doc:`memcached_strerror`