1 ========================
2 Configuring Libmemcached
3 ========================
5 .. index:: object: memcached_st
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
25 Libmemcached implements a custom language for configuring and modifying
26 servers. By passing in an option string you can generate a memcached_st object
27 that you can use in your application directly.
29 .. describe:: --SERVER=<servername>:<optional_port>/?<optional_weight>
31 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.
33 .. describe:: --VERIFY-KEY
35 Verify that keys that are being used fit within the design of the protocol being used.
37 .. describe:: --REMOVE_FAILED_SERVERS
39 Enable the behavior MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS.
41 .. describe:: --BINARY-PROTOCOL
43 Force all connections to use the binary protocol.
45 .. describe:: --BUFFER-REQUESTS
47 Enable MEMCACHED_BEHAVIOR_BUFFER_REQUESTS.
49 .. describe:: --CONFIGURE-FILE=
51 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.
53 .. describe:: --CONNECT-TIMEOUT=
55 Enable MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT.
57 .. describe:: --DISTRIBUTION=
59 Set the distribution model used by the client. See :manpage:`` for more details.
63 Set the hashing alogrthm used for placing keys on servers.
65 .. describe:: --HASH-WITH-NAMESPACE
67 When enabled the prefix key will be added to the key when determining which
68 server to store the data in.
70 .. describe:: --NOREPLY
72 Enable "no reply" for all calls that support this. It is highly recommended
73 that you use this option with the binary protocol only.
75 .. describe:: --NUMBER-OF-REPLICAS=
77 Set the nummber of servers that keys will be replicated to.
79 .. describe:: --RANDOMIZE-REPLICA-READ
81 Select randomly the server within the replication pool to read from.
83 .. describe:: --SORT-HOSTS
85 When adding new servers always calculate their distribution based on sorted naming order.
87 .. describe:: --SUPPORT-CAS
89 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SUPPORT_CAS
91 .. describe:: --USE-UDP
93 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_USE_UDP
95 .. describe:: --NAMESPACE=
97 A namespace is a container that provides context for keys, only other
98 requests that know the namespace can access these values. This is
99 accomplished by prepending the namespace value to all keys.
102 **********************
103 Mecached Pool Options:
104 **********************
106 .. describe:: --POOL-MIN
108 Initial size of pool.
110 .. describe:: --POOL-MAX
112 Maximize size of the pool.
118 .. describe:: --TCP-NODELAY
120 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_TCP_NODELAY
122 .. describe:: --TCP-KEEPALIVE
124 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_TCP_KEEPALIVE
126 .. describe:: --RETRY-TIMEOUT=
128 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_RETRY_TIMEOUT
130 .. describe:: --SERVER-FAILURE-LIMIT=
132 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT
134 .. describe:: --SND-TIMEOUT=
136 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SND_TIMEOUT
138 .. describe:: --SOCKET-RECV-SIZE=
140 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE
142 .. describe:: --SOCKET-SEND-SIZE=
144 See :manpage:`memcached_behavior_set(3)` for MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
146 .. describe:: --POLL-TIMEOUT=
148 That sets the value of the timeout used by :manpage: `poll()`.
150 .. describe:: --IO-BYTES-WATERMARK=
152 .. describe:: --IO-KEY-PREFETCH=
154 .. describe:: --IO-MSG-WATERMARK=
156 .. describe:: --TCP-KEEPIDLE
158 .. describe:: --RCV-TIMEOUT=
167 .. describe:: INCLUDE
169 Include a file in configuration. Unlike --CONFIGURE-FILE= this will not reset memcached_st
173 Reset memcached_st and continue to process.
177 End configutation processing.
181 End configutation processing and throw an error.
189 memcached() returns a pointer to the memcached_st that was
190 created (or initialized). On an allocation failure, it returns NULL.
201 const char *config_string= "--SERVER=host10.example.com --SERVER=host11.example.com --SERVER=host10.example.com"
202 memcached_st *memc= memcached(config_string, strlen(config_string);
206 memcached_free(memc);
215 To find out more information please check:
216 `http://libmemcached.org/ <http://libmemcached.org/>`_
225 :manpage:`memcached(1)` :manpage:`libmemcached(3)` :manpage:`memcached_strerror(3)`