libmemcached
Server Functions
The libmemcached
API uses a list of servers, stored within the memcached_server_st
structure, to act as the list of servers used by the rest of the functions. To use memcached
, you first create the server list, and then apply the list of servers to a valid libmemcached
object.
Because the list of servers, and the list of servers within an active libmemcached
object can be manipulated separately, you can update and manage server lists while an active libmemcached
interface is running.
The functions for manipulating the list of servers within a memcached_st
structure are:
memcached_return memcached_server_add (memcached_st *ptr, char *hostname, unsigned int port);
Adds a server, using the given hostname
and port
into the memcached_st
structure given in ptr
.
memcached_return memcached_server_add_unix_socket (memcached_st *ptr, char *socket);
Adds a Unix socket to the list of servers configured in the memcached_st
structure.
unsigned int memcached_server_count (memcached_st *ptr);
Returns a count of the number of configured servers within the memcached_st
structure.
memcached_server_st * memcached_server_list (memcached_st *ptr);
Returns an array of all the defined hosts within a memcached_st
structure.
memcached_return memcached_server_push (memcached_st *ptr, memcached_server_st *list);
Pushes an existing list of servers onto list of servers configured for a current memcached_st
structure. This adds servers to the end of the existing list, and duplicates are not checked.
The memcached_server_st
structure can be used to create a list of memcached
servers which can then be applied individually to memcached_st
structures.
memcached_server_st * memcached_server_list_append (memcached_server_st *ptr, char *hostname, unsigned int port, memcached_return *error);
Adds a server, with hostname
and port
, to the server list in ptr
. The result code is handled by the error
argument, which should point to an existing memcached_return
variable. The function returns a pointer to the returned list.
unsigned int memcached_server_list_count (memcached_server_st *ptr);
Returns the number of the servers in the server list.
void memcached_server_list_free (memcached_server_st *ptr);
Frees the memory associated with a server list.
memcached_server_st *memcached_servers_parse (char *server_strings);
Parses a string containing a list of servers, where individual servers are separated by a comma, space, or both, and where individual servers are of the form
. The return value is a server list structure.
server
[:port
]