Memcac...ervers(3pm)
π Memcac...ervers(3pm) π
okay bestie, so this is a chunk of the User Contributed Perl Documentation for the <rainbow>Memcac...ervers</rainbow> section, and it's literally all about managing your server list. it's giving infrastructure queen energy and i'm obsessed. π
β¨ NAME β¨
memcached_server_count, memcached_server_list, memcached_server_add, memcached_server_push, memcached_server_get_last_disconnect, memcached_server_cursor β the whole squad that handles Manage server list. π«Ά
π LIBRARY π
C Client Library for memcached (libmemcached, -lmemcached) β that's the C client, not the Perl one, don't get it twisted. π
π SYNOPSIS π
here's the whole cast list, verbatim, no cap:
#include <memcached.h>
uint32_t memcached_server_count (memcached_st *ptr);
memcached_return_t
memcached_server_add (memcached_st *ptr,
const char *hostname,
in_port_t port);
memcached_return_t
memcached_server_add_udp (memcached_st *ptr,
const char *hostname,
in_port_t port);
memcached_return_t
memcached_server_add_unix_socket (memcached_st *ptr,
const char *socket);
memcached_return_t
memcached_server_push (memcached_st *ptr,
const memcached_server_st *list);
memcached_server_instance_st
memcached_server_by_key (const memcached_st *ptr,
const char *key,
size_t key_length,
memcached_return_t *error);
memcached_server_instance_st
memcached_server_get_last_disconnect (const memcached_st *ptr)
memcached_return_t
memcached_server_cursor(const memcached_st *ptr,
const memcached_server_fn *callback,
void *context,
uint32_t number_of_callbacks);
πΈ DESCRIPTION πΈ
so libmemcached(3) does its whole thing on a list of hosts, and the order of those hosts? that's literally what determines routing to keys. like, the lineup matters, bestie. π
there are functions here to add keys to memcached_st structures, and if you wanna manipulate lists of servers themselves, go look at memcached_server_st(3) instead. different vibe, different page. π«
memcached_server_count()β hands you the count of how many servers yourmemcached_ststructure is currently using. a headcount. a lil census. π’memcached_server_add()β pushes one single TCP server into thememcached_ststructure, and it lands at the end. duplicate servers are allowed, so nothing's getting checked, no dedupe, sorry girl. and heads up: if you run this while theMEMCACHED_BEHAVIOR_USE_UDPbehavior is set, you get aMEMCACHED_INVALID_HOST_PROTOCOL. pick a lane. πmemcached_server_add_udp()β same deal but UDP: pushes a single UDP server into thememcached_ststructure, placed at the end, duplicates allowed, no checking. and the reverse gotcha: run this without setting theMEMCACHED_BEHAVIOR_USE_UDPbehavior and you getMEMCACHED_INVALID_HOST_PROTOCOL. it's giving "you had one job". πmemcached_server_add_unix_socket()β pushes a single UNIX socket into thememcached_ststructure, at the end, duplicates allowed, not checked. one very specific rule tho: the filename length has to be one character less thanMEMCACHED_MAX_HOST_LENGTH. count your characters, babe. π§memcached_server_push()β this one yeets an array ofmemcached_server_stinto thememcached_ststructure, at the end, duplicates allowed, not checked. and here's the tea: a copy is made of the structure, so the list you handed over (and any operations you do on that list) are not saved. it's a snapshot, not a situationship. πΈmemcached_server_by_key()β give it a key and it tells you which server would be used for assignment. the returned structure is cloned from its original, so you must free it. ifNULLcomes back, go consult*error. and free that returned structure withmemcached_server_free(). free it. free it. π«Άmemcached_server_get_last_disconnect()β returns a pointer to the last server that had a connection problem. important nuance: this does not mean that particular server is currently dead β but if the library is reporting a server dead, the returned one is a very good candidate. prime suspect, not convicted. π΅οΈmemcached_server_cursor()β takes amemcached_stand loops through the list of hosts currently in the cursor, calling the list of callback functions you provided. you can optionally pass a value in viacontext, and that gets handed to each callback function. if any callback returns an error, the loop is terminated, periodt. also:memcached_server_cursor()gets passed the original caller'smemcached_stin its current state. π
π₯ RETURN π₯
Varies β go read the particular function you're nosy about. it's giving "results may vary". π
π HOME π
wanna find out more? go here, bestie: <https://launchpad.net/libmemcached>
π AUTHOR π
Brian Aker, <brian@tangent.org> β the icon, the legend, the moment. β¨
π SEE ALSO π
and that's a wrap on the Memcac...ervers(3pm) page!! this lil doc came to you via perl v5.42.3 on 2026-08-19 β go forth and manage your servers, you absolute main character. no cap, ily. π
π¦π
π¦ where this page comes from
- ubuntu stonking: libmemcached-libmemcached-perl 1.001801+dfsg-6build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms