LIBMEMCACHE...NFIGURATION(3)
πΈ NAME πΈ
okay so this is the libmemcached-awesome manual page LIBMEMCACHE...NFIGURATION(3), section 3 of the manual, and it's all about this one function:
libmemcached_check_configuration β literally it's the libmemcached Documentation, that's the whole name, bestie π
β¨ SYNOPSIS β¨
#include <libmemcached-1.0/memcached.h>
Compile and link with -lmemcached
memcached_st *memcached(const char *string, size_t string_length)
Parameters π
stringβ the configuration string, queenstring_lengthβ how long that configuration string is, without any terminating zero (no sneaky\0counted, okay?)
Returns β an allocated and initialized memcached_st struct π«Ά
memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, char *error_buffer, size_t error_buffer_size)
Parameters π¦
option_stringβ the configuration stringlengthβ length of the configuration string, again without any terminating zeroerror_bufferβ the buffer where any error message gets storederror_buffer_sizeβ how much room theerror_bufferactually has
Returns β a memcached_return_t indicating success β¨
π DESCRIPTION π
okay so libmemcached straight up invented its own little custom language for configuring and modifying servers. You pass in an option string, and boom β you get a memcached_st object you can use in your application directly. it's giving build-your-own-memcached-client, and honestly? iconic π
π General Options:
--SERVER=<servername>:<optional_port>/?<optional_weight>β hand over a servername for the client to use. And if you also give a weight, weighting kicks in across all hosts, with every server starting out at a default weight of 1 π--SOCKET=\"<filepath>/?<optional_weight>\"β hand over a filepath to a UNIX socket file. Give a weight too and weighting happens across all hosts, each server getting a default weight of 1.--VERIFY-KEYβ double-check that the keys you're using actually fit inside the design of the protocol you're using. vibe check for keys, fr fr π--REMOVE_FAILED_SERVERSβ turns on the behaviorMEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS. bye bye failed servers π--BINARY-PROTOCOLβ forces all connections to use the binary protocol. no exceptions.--BUFFER-REQUESTSβ please go look atMEMCACHED_BEHAVIOR_BUFFER_REQUESTS, that's your girl.--CONFIGURE-FILE=β give it a configuration file to load requests from. > β οΈ but beware bestie: using a configuration file means libmemcached will resetmemcached_stbased on information that's only contained in that file. your old settings? gone. π--CONNECT-TIMEOUT=β seememcached_behavior_set()forMEMCACHED_BEHAVIOR_CONNECT_TIMEOUT.--DISTRIBUTION=β sets the distribution model the client uses. seememcached_behavior_set()for the deets.--HASH=β sets the hashing algorithm used for placing keys on servers.--HASH-WITH-NAMESPACEβ when this is enabled, the prefix key gets added to the key when figuring out which server the data lives on.--NOREPLYβ enables "no reply" for all the calls that support it. and it is highly recommended that you only use this with the binary protocol, okay? don't be messy.--NUMBER-OF-REPLICAS=β sets how many servers your keys get replicated to.--RANDOMIZE-REPLICA-READβ picks the server to read from randomly out of the replication pool. main character selection energy π²--SORT-HOSTSβ when new servers get added, always calculate their distribution based on sorted naming order.--SUPPORT-CASβ seememcached_behavior_set()forMEMCACHED_BEHAVIOR_SUPPORT_CAS.--USE-UDPβ seememcached_behavior_set()forMEMCACHED_BEHAVIOR_USE_UDP.--NAMESPACE=β a namespace is a container that gives context to keys, and only other requests that know the namespace can get to those values. how does it do it? by prepending the namespace value to all your keys. cute, simple, effective π
π§ Memcached Pool Options:
--POOL-MINβ initial size of the pool.--POOL-MAXβ maximize size of the pool.
π I/O Options:
--TCP-NODELAYβ seememcached_behavior_set()forMEMCACHED_BEHAVIOR_TCP_NODELAY.--TCP-KEEPALIVEβ seememcached_behavior_set()forMEMCACHED_BEHAVIOR_TCP_KEEPALIVE.--RETRY-TIMEOUT=β seememcached_behavior_set()forMEMCACHED_BEHAVIOR_RETRY_TIMEOUT.--SERVER-FAILURE-LIMIT=β seememcached_behavior_set()forMEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT.--SND-TIMEOUT=β seememcached_behavior_set()forMEMCACHED_BEHAVIOR_SND_TIMEOUT.--SOCKET-RECV-SIZE=β seememcached_behavior_set()forMEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE.--SOCKET-SEND-SIZE=β seememcached_behavior_set()forMEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE.--POLL-TIMEOUT=β sets the timeout used bypoll(3).--IO-BYTES-WATERMARK=β that's it, that's the whole entry, the page doesn't tell us more π--IO-KEY-PREFETCH=β same situation, name only, no description on the page π--IO-MSG-WATERMARK=β again, just the name, that's all we got π--TCP-KEEPIDLEβ name only, bestie, no extra details here.--RCV-TIMEOUT=β name only too, we keep it real.
π Other Options:
INCLUDEβ includes a file in the configuration. and unlike--CONFIGURE-FILE=, this one will not resetmemcached_st. huge difference, don't mix them up π«ΆRESETβ resetsmemcached_stand keeps on processing. clean slate, keep going πENDβ ends configuration processing. that's a wrap.ERRORβ ends configuration processing and throws an error. dramatic exit, love that for us.
π± ENVIRONMENT π±
LIBMEMCACHED
β RETURN VALUE β
memcached() returns a pointer to the memcached_st that got created (or initialized). and if an allocation fails? it returns NULL. so always check your pointers, bestie, no cap π«Ά
π EXAMPLE π
const char *config_string=
"--SERVER=host10.example.com "
"--SERVER=host11.example.com "
"--SERVER=host10.example.com";
memcached_st *memc= memcached(config_string, strlen(config_string));
{
// ...
}
memcached_free(memc);
π₯ SEE ALSO π₯
memcached(1) libmemcached(3) memcached_strerror(3)
and that's the whole page, periodt π this was libmemcached-awesome manual page LIBMEMCACHE...NFIGURATION(3), version 1.1, dated Jul 24, 2025 β go forth and configure your servers, you absolute icon β¨ππ¦
π¦ where this page comes from
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms