1 Managing the servers used by memcached_st
2 =========================================
7 #include <libmemcached/memcached.h>
8 Compile and link with -lmemcached
10 .. function:: uint32_t memcached_server_count (memcached_st *ptr)
12 :param ptr: pointer to initialized `memcached_st` struct
13 :returns: number of configured servers
15 .. function:: memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port)
17 :param ptr: pointer to initialized `memcached_st` struct
18 :param hostname: hostname or IP address of the TCP server to add
19 :param port: port of the TCP server
20 :returns: `memcached_return_t` indicating success
22 .. function:: memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port)
24 :param ptr: pointer to initialized `memcached_st` struct
25 :param hostname: hostname or IP address of the UDP server to add
26 :param port: port of the UDP server
27 :returns: `memcached_return_t` indicating success
29 .. function:: memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket)
31 :param ptr: pointer to initialized `memcached_st` struct
32 :param socket: path to the UNIX socket of the server to add
33 :returns: `memcached_return_t` indicating success
35 .. function:: memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list)
37 :param ptr: pointer to initialized `memcached_st` struct
38 :param list: pre-configured list of servers to push
39 :returns: `memcached_return_t` indicating success
41 .. function:: const memcached_instance_st * memcached_server_by_key (memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error)
43 :param ptr: pointer to initialized `memcached_st` struct
44 :param key: key to hash and lookup a server
45 :param key_length: length of `key` without any terminating zero
46 :param error: pointer to `memcached_return_t` indicating success
47 :returns: the server instance to be used for storing/retrieving `key`
49 .. function:: const memcached_instance_st * memcached_server_get_last_disconnect (const memcached_st *ptr)
51 :param ptr: pointer to initialized `memcached_st` struct
52 :returns: the instance of the last server for which there was a connection problem
54 .. function:: memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks)
56 :param ptr: pointer to initialized `memcached_st` struct
57 :param callback: list of `memcached_server_fn` to be called for each server instance
58 :param context: pointer to user supplied context for the callback
59 :param number_of_callbacks: number of callbacks supplied
60 :returns: `memcached_return_t` indicating success
62 .. type:: memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, const memcached_instance_st * server, void *context)
64 :param ptr: pointer to the `memcached_st` struct
65 :param server: pointer to `memcached_instance_st`
66 :param context: pointer to user supplied context
67 :returns: `memcached_return_t` indicating success
72 `libmemcached` performs operations on a list of hosts. The order of
73 these hosts determine routing to keys. Functions are provided to add keys to
74 `memcached_st` structures. To manipulate lists of servers see
75 `memcached_server_st`.
77 :func:`memcached_server_count` provides you a count of the current number of
78 servers being used by a :type:`memcached_st` structure.
80 :func:`memcached_server_add` pushes a single TCP server into the
81 :type:`memcached_st` structure. This server will be placed at the end.
82 Duplicate servers are allowed, so duplication is not checked. Executing this
83 function with the `MEMCACHED_BEHAVIOR_USE_UDP` behavior set will result in
84 a `MEMCACHED_INVALID_HOST_PROTOCOL`.
86 :func:`memcached_server_add_udp` pushes a single UDP server into the
87 :type:`memcached_st` structure. This server will be placed at the end. Duplicate
88 servers are allowed, so duplication is not checked. Executing this function
89 without setting the `MEMCACHED_BEHAVIOR_USE_UDP` behavior will result in a
90 `MEMCACHED_INVALID_HOST_PROTOCOL`.
92 :func:`memcached_server_add_unix_socket` pushes a single UNIX socket into the
93 :type:`memcached_st` structure. This UNIX socket will be placed at the end.
94 Duplicate servers are allowed, so duplication is not checked. The length
95 of the filename must be one character less than `MEMCACHED_MAX_HOST_LENGTH`.
97 :func:`memcached_server_push` pushes an array of :type:`memcached_server_st`
98 into the :type:`memcached_st` structure. These servers will be placed at
99 the end. Duplicate servers are allowed, so duplication is not checked. A
100 copy is made of structure so the list provided (and any operations on
101 the list) are not saved.
103 :func:`memcached_server_by_key` allows you to provide a key and retrieve the
104 server which would be used for assignment.
106 :func:`memcached_server_get_last_disconnect` returns a pointer to the last
107 server for which there was a connection problem. It does not mean this
108 particular server is currently dead but if the library is reporting a server
109 is, the returned server is a very good candidate.
111 :func:`memcached_server_cursor` takes a memcached_st and loops through the
112 list of hosts currently in the cursor calling the list of callback
113 functions provided. You can optionally pass in a value via
114 context which will be provided to each callback function. An error
115 return from any callback will terminate the loop.
116 :func:`memcached_server_cursor` is passed the original caller
117 :type:`memcached_st` in its current state.
122 Varies, see particular functions.
129 :manpage:`memcached(1)`
130 :manpage:`libmemcached(3)`
131 :manpage:`memcached_server_st(3)`
132 :manpage:`memcached_strerror(3)`
136 * :manpage:`memcached(1)`
137 * :doc:`../libmemcached`
138 * :doc:`memcached_server_st`
139 * :doc:`memcached_strerror`