1 ========================
2 Configuring Libmemcached
3 ========================
11 #include <libmemcached/memcached.h>
13 .. c:function:: memcached_st *memcached(const char *string, size_t string_length)
15 .. c:function:: memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, char *error_buffer, size_t error_buffer_size)
17 Compile and link with -lmemcached
24 Libmemcached implements a custom language for configuring and modifying
25 servers. By passing in an option string you can generate a ``memcached_st`` object
26 that you can use in your application directly.
28 .. describe:: --SERVER=<servername>:<optional_port>/?<optional_weight>
30 Provide a servername to be used by the client. Providing a weight will cause weighting to occur with all hosts with each server getting a default weight of 1.
32 .. describe:: --SOCKET=<filepath>/?<optional_weight>
34 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.
36 .. describe:: --VERIFY-KEY
38 Verify that keys that are being used fit within the design of the protocol being used.
40 .. describe:: --REMOVE_FAILED_SERVERS
42 Enable the behavior MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS.
44 .. describe:: --BINARY-PROTOCOL
46 Force all connections to use the binary protocol.
48 .. describe:: --BUFFER-REQUESTS
50 Enable MEMCACHED_BEHAVIOR_BUFFER_REQUESTS.
52 .. describe:: --CONFIGURE-FILE=
54 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.
56 .. describe:: --CONNECT-TIMEOUT=
58 Enable MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT.
60 .. describe:: --DISTRIBUTION=
62 Set the distribution model used by the client. See :manpage:`` for more details.
66 Set the hashing alogrthm used for placing keys on servers.
68 .. describe:: --HASH-WITH-NAMESPACE
70 When enabled the prefix key will be added to the key when determining which
71 server to store the data in.
73 .. describe:: --NOREPLY
75 Enable "no reply" for all calls that support this. It is highly recommended
76 that you use this option with the binary protocol only.
78 .. describe:: --NUMBER-OF-REPLICAS=
80 Set the nummber of servers that keys will be replicated to.
82 .. describe:: --RANDOMIZE-REPLICA-READ
84 Select randomly the server within the replication pool to read from.
86 .. describe:: --SORT-HOSTS
88 When adding new servers always calculate their distribution based on sorted naming order.
90 .. describe:: --SUPPORT-CAS
92 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SUPPORT_CAS
94 .. describe:: --USE-UDP
96 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_USE_UDP
98 .. describe:: --NAMESPACE=
100 A namespace is a container that provides context for keys, only other
101 requests that know the namespace can access these values. This is
102 accomplished by prepending the namespace value to all keys.
105 **********************
106 Mecached Pool Options:
107 **********************
109 .. describe:: --POOL-MIN
111 Initial size of pool.
113 .. describe:: --POOL-MAX
115 Maximize size of the pool.
121 .. describe:: --TCP-NODELAY
123 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_TCP_NODELAY
125 .. describe:: --TCP-KEEPALIVE
127 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_TCP_KEEPALIVE
129 .. describe:: --RETRY-TIMEOUT=
131 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_RETRY_TIMEOUT
133 .. describe:: --SERVER-FAILURE-LIMIT=
135 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
137 .. describe:: --SND-TIMEOUT=
139 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SND_TIMEOUT
141 .. describe:: --SOCKET-RECV-SIZE=
143 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
145 .. describe:: --SOCKET-SEND-SIZE=
147 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
149 .. describe:: --POLL-TIMEOUT=
151 That sets the value of the timeout used by :manpage: `poll()`.
153 .. describe:: --IO-BYTES-WATERMARK=
155 .. describe:: --IO-KEY-PREFETCH=
157 .. describe:: --IO-MSG-WATERMARK=
159 .. describe:: --TCP-KEEPIDLE
161 .. describe:: --RCV-TIMEOUT=
170 .. describe:: INCLUDE
172 Include a file in configuration. Unlike --CONFIGURE-FILE= this will not reset memcached_st
176 Reset memcached_st and continue to process.
180 End configutation processing.
184 End configutation processing and throw an error.
192 :c:func:`memcached()` returns a pointer to the memcached_st that was
193 created (or initialized). On an allocation failure, it returns NULL.
204 const char *config_string= "--SERVER=host10.example.com --SERVER=host11.example.com --SERVER=host10.example.com"
205 memcached_st *memc= memcached(config_string, strlen(config_string);
209 memcached_free(memc);
218 To find out more information please check:
219 `http://libmemcached.org/ <http://libmemcached.org/>`_
228 :manpage:`memcached(1)` :manpage:`libmemcached(3)` :manpage:`memcached_strerror(3)`