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