MEMCACHED_SERVERS_PARSE(3)

πŸ’– MEMCACHED_SERVERS_PARSE πŸ’–

okay bestie, so this is a page from libmemcached-awesome, manual section 3 (that's the library-functions section, iykyk). It's the whole "how do I hold a list of memcached servers in my hands" situation, and honestly? it's giving infrastructure realness. Let's get into it. 🧚


✨ 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)

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

uint32_t memcached_server_list_count(memcached_server_list_st list)

const char *memcached_server_error(const memcached_instance_st
*instance)

void memcached_server_error_reset(const memcached_instance_st *list)

🌸 parameters & returns, function by function

memcached_server_list_free

  • Parameters
    • list β€” an instance of an initialized memcached_server_list_st object

memcached_server_list_append

  • Parameters
    • list β€” an instance of an existing memcached_server_list_st, or nullptr if you wanna create one from scratch, no judgment
    • hostname β€” the hostname or path to the socket. If it's null, it just defaults to localhost 🏠
    • port β€” the port to use. If it's 0, it defaults to 11211
    • error β€” pointer where any memcached_return_t error gets stored, indicating success
  • Returns β€” a shiny new instance of memcached_server_list_st on success, or nullptr on failure 😭

memcached_server_list_count

  • Parameters
    • list β€” instance of memcached_server_list_st
  • Returns β€” the count of servers in the list, literally just the number, that's the whole vibe

memcached_server_error

  • Parameters
    • instance β€” pointer to an initialized memcached_instance_st object
  • Returns β€” the last error message sent from the server to the client

memcached_server_error_reset

Deprecated since version 0.39. 🚫

memcached_servers_parse

Deprecated since version 0.39. 🚫

See memcached().


🌈 DESCRIPTION 🌈

okay so here's the tea β˜• β€” libmemcached operates on a list of hosts, and those hosts live in memcached_server_st structures. And bestie, listen: you should not modify these structures directly. Hands off! πŸ™ˆ Functions are provided to modify these structures, and that's the whole point of this page.

memcached_server_list() is what you use to get an array of all defined hosts. Fun lore drop: this was incorrectly documented as "requiring free" up till version 0.39. so if you were out here freeing it before 0.39, that was the old misinformation, not you being bad at this. πŸ’€

memcached_server_list_free() deallocates all the memory associated with the array of memcached_server_st that you passed to it. Cleanup queen. 🧹

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 gets set to the default port of a memcached server. slay.

DEPRECATED memcached_servers_parse() β€” please see memcached(). she's retired, let her rest. πŸ‘‘

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, "to to", we keep the original's whole vibe, no edits πŸ’…)

And the history lesson, because we love context: before version 0.39, these 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. glow-up arc, honestly. ✨


πŸ’« RETURN VALUE πŸ’«

Varies β€” see particular functions. (yes really, that's the answer, go read the individual ones above bestie 🫢)


πŸ‘€ SEE ALSO πŸ‘€


and that's the whole page, no cap. this was libmemcached-awesome version 1.1, dated Jul 24, 2025 β€” go forth and manage your server lists responsibly, main character. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from