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