docs: ws
[awesomized/libmemcached] / docs / source / libmemcached / memcached_servers.rst
1 ========================================================
2 Manipulate the server information stored in memcached_st
3 ========================================================
4
5 SYNOPSIS
6 --------
7
8 #include <libmemcached/memcached.h>
9
10 .. type:: memcached_server_fn
11
12 .. function:: uint32_t memcached_server_count (memcached_st *ptr)
13
14 .. function:: memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port)
15
16 .. function:: memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port)
17
18 .. function:: memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket)
19
20 .. function:: memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list)
21
22 .. function:: const memcached_instance_st * memcached_server_by_key (memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error)
23
24 .. function:: const memcached_instance_st * memcached_server_get_last_disconnect (const memcached_st *ptr)
25
26 .. function:: memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks)
27
28 compile and link with -lmemcached
29
30 DESCRIPTION
31 -----------
32
33 `libmemcached` performs operations on a list of hosts. The order of
34 these hosts determine routing to keys. Functions are provided to add keys to
35 memcached_st structures. To manipulate lists of servers see
36 memcached_server_st(3).
37
38 :func:`memcached_server_count` provides you a count of the current number of
39 servers being used by a :type:`memcached_st` structure.
40
41 :func:`memcached_server_add` pushes a single TCP server into the :type:`memcached_st` structure. This server will be placed at the end. Duplicate servers
42 are allowed, so duplication is not checked. Executing this function with the `MEMCACHED_BEHAVIOR_USE_UDP` behavior set will result in a `MEMCACHED_INVALID_HOST_PROTOCOL`.
43
44 :func:`memcached_server_add_udp` pushes a single UDP server into the :type:`memcached_st` structure. This server will be placed at the end. Duplicate
45 servers are allowed, so duplication is not checked. Executing this function with out setting the `MEMCACHED_BEHAVIOR_USE_UDP` behavior will result in a
46 `MEMCACHED_INVALID_HOST_PROTOCOL`.
47
48 :func:`memcached_server_add_unix_socket` pushes a single UNIX socket into the :type:`memcached_st` structure. This UNIX socket will be placed at the end.
49 Duplicate servers are allowed, so duplication is not checked. The length
50 of the filename must be one character less than `MEMCACHED_MAX_HOST_LENGTH`.
51
52 :func:`memcached_server_push` pushes an array of :type:`memcached_server_st` into the :type:`memcached_st` structure. These servers will be placed at
53 the end. Duplicate servers are allowed, so duplication is not checked. A
54 copy is made of structure so the list provided (and any operations on
55 the list) are not saved.
56
57 :func:`memcached_server_by_key` allows you to provide a key and retrieve the
58 server which would be used for assignment.
59
60 :func:`memcached_server_get_last_disconnect` returns a pointer to the last
61 server for which there was a connection problem. It does not mean this
62 particular server is currently dead but if the library is reporting a server
63 is, the returned server is a very good candidate.
64
65 :func:`memcached_server_cursor` takes a memcached_st and loops through the
66 list of hosts currently in the cursor calling the list of callback
67 functions provided. You can optionally pass in a value via
68 context which will be provided to each callback function. An error
69 return from any callback will terminate the loop. :func:`memcached_server_cursor` is passed the original caller :type:`memcached_st` in its current state.
70
71 ------
72 RETURN
73 ------
74
75 Varies, see particular functions.
76
77 --------
78 SEE ALSO
79 --------
80
81 .. only:: man
82
83 :manpage:`memcached(1)`
84 :manpage:`libmemcached(3)`
85 :manpage:`memcached_strerror(3)`