MEMCACHED_S...LIST_APPEND(3)

πŸ’– MEMCACHED_S...LIST_APPEND πŸ’–

okay bestie, gather round, we're doing the libmemcached-awesome manual page for memcached_server_list_append, and honestly? it's giving "quiet little utility that runs the whole friend group." let's get into it 🫢


✨ NAME ✨

memcached_server_list_append β€” libmemcached Documentation

like yes, that's the whole name section, the docs really said "short and mysterious" πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <libmemcached/memcached.h>
       Compile and link with -lmemcached

typedef struct memcached_instance_st memcached_instance_st

typedef struct memcached_server_st memcached_server_st

typedef struct memcached_server_st *memcached_server_list_st

void memcached_server_list_free(memcached_server_list_st list)

       Parameters
              list -- instance of initialized memcached_server_list_st
              object

memcached_server_list_st
memcached_server_list_append(memcached_server_list_st list, const char
*hostname, in_port_t port, memcached_return_t *error)

       Parameters

              β€’ list -- instance of an existing memcached_server_list_st
                or nullptr to create one

              β€’ hostname -- the hostname or path to the socket, defaults
                to localhost if null

              β€’ port -- the port to use, defaults to 11211 if 0

              β€’ error -- pointer to store any memcached_return_t error
                indicating success

       Returns
              new instance of memcached_server_list_st on success or
              nullptr on failure

uint32_t memcached_server_list_count(memcached_server_list_st list)

       Parameters
              list -- instance of memcached_server_list_st

       Returns
              count of servers in the list

const char *memcached_server_error(const memcached_instance_st
*instance)

       Parameters
              instance -- pointer to an initialized
              memcached_instance_st object

       Returns
              last error message sent from the server to the client

void memcached_server_error_reset(const memcached_instance_st *list)
       Deprecated since version 0.39.

void memcached_servers_parse()
       Deprecated since version 0.39.

       See memcached().

so that's the lineup πŸ’– a whole little cast of structs and functions, and we love them all. let me break down what each one is doing, because the way this page just lists them with no commentary is lowkey criminal:

  • memcached_server_list_free(memcached_server_list_st list) β€” takes an list that's an instance of initialized memcached_server_list_st object and frees it. bye bye, memory πŸ¦‹
  • memcached_server_list_append(memcached_server_list_st list, const char *hostname, in_port_t port, memcached_return_t *error) β€” the main character of this whole page, ngl. returns a new instance of memcached_server_list_st on success or nullptr on failure. the params:
    • list β€” instance of an existing memcached_server_list_st or nullptr to create one (so nullptr = fresh start, iconic)
    • hostname β€” the hostname or path to the socket, defaults to localhost if null
    • port β€” the port to use, defaults to 11211 if 0
    • error β€” pointer to store any memcached_return_t error indicating success
  • memcached_server_list_count(memcached_server_list_st list) β€” returns count of servers in the list. math but make it cute πŸ”’
  • memcached_server_error(const memcached_instance_st *instance) β€” returns the last error message sent from the server to the client. give it an instance that's a pointer to an initialized memcached_instance_st object. it's the receipts function fr fr 😭
  • memcached_server_error_reset(const memcached_instance_st *list) β€” Deprecated since version 0.39. that's it. that's the note. she's retired πŸ’€
  • memcached_servers_parse() β€” Deprecated since version 0.39. See memcached().
bestie warning: those last two are deprecated since version 0.39 β€” like, don't build your whole personality on them, okay? πŸ™ˆ

🌸 DESCRIPTION 🌸

so here's the vibe. libmemcached operates on a list of hosts which are stored in memcached_server_st structures. and the important part, listen up: You should not modify these structures directly. hands off the struct, bestie πŸ™…β€β™€οΈ functions are provided to modify these structures β€” that's the whole point, use the functions.

memcached_server_list() is used to provide an array of all defined hosts. and here's a fun little lore drop: this was incorrectly documented as "requiring free" up till version 0.39. so all that time people were out here freeing things that didn't need freeing. a mess. we don't do that anymore ✨

memcached_server_list_free() deallocates all memory associated with the array of memcached_server_st that you passed to it. so when you DO pass it, it actually handles the cleanup. slay.

memcached_server_list_append() adds a server to the end of a memcached_server_st array. on error null will be returned and the memcached_return_t pointer you passed into the function will be set with the appropriate error. and if the value of port is zero, it is set to the default port of a memcached server. convenient? yes. πŸ‘‘

DEPRECATED memcached_servers_parse(), please see memcached() β€” like I said, she's retired, redirect your energy πŸŽ€

memcached_server_error() can be used to look at the text of the last error message sent by the server to to the client. (yes, the original says "to to", and I'm keeping it, it's part of the heritage now 😭)

before version 0.39 theses functions used a memcached_server_st *. in 0.39 memcached_server_st * was aliased to memcached_server_list_st. this was done for a style reason to help clean up some concepts in the code. basically a glow-up for the type system, we love a rebrand πŸ’…


🌈 RETURN VALUE 🌈

Varies, see particular functions.

that's the whole section. honestly? iconic minimalism. every function has its own little return story, go read the one you need, bestie πŸ¦‹


πŸ’œ SEE ALSO πŸ’œ

memcached(1) libmemcached(3) memcached_servers(3) memcached_strerror(3)

the whole friend group πŸ’– go say hi.


and that's the page!! this is libmemcached-awesome, version 1.1, dated Jul 24, 2025 β€” so yeah, fresh, current, no cap. go build something cute with your server lists, and remember: don't touch the structs directly, use the functions, free responsibly, and never trust documentation from before 0.39 πŸ«Άβœ¨πŸ’…

πŸ“¦ where this page comes from