LIBMEMCACHED_CONFIGURATION(3)
π LIBMEMCACHED_CONFIGURATION(3) π
okay so bestie, welcome to the libmemcached-awesome page about libmemcached_configuration β aka the libmemcached Documentation. it's the whole vibe of how you talk to libmemcached in its own lil language. let's get into it π«Ά
β¨ 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 stringstring_lengthβ how long that configuration string is, without any terminating zero
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β how long the configuration string is, again without any terminating zeroerror_bufferβ the buffer where any error message gets storederror_buffer_sizeβ how much space theerror_bufferactually has available
Returns
a memcached_return_t that indicates success β¨
πΈ DESCRIPTION πΈ
so here's the tea: libmemcached ships its own custom language for configuring and modifying servers. you hand it an option string, and boom β you get a memcached_st object you can use directly in your application. no cap. π
π General Options: π
--SERVER=<servername>:<optional_port>/?<optional_weight>β gives a servername for the client to use. if you also pass a weight, weighting happens across all hosts, and each server gets a default weight of1.--SOCKET=\"<filepath>/?<optional_weight>\"β gives a filepath to a UNIX socket file. same deal: passing a weight causes weighting to occur with all hosts, with each server getting a default weight of1.--VERIFY-KEYβ verifies that the keys you're using actually fit within the design of the protocol you're using. vibe check on your keys, basically.--REMOVE_FAILED_SERVERSβ enables the behaviorMEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS.--BINARY-PROTOCOLβ forces every connection to use the binary protocol.--BUFFER-REQUESTSβ please seeMEMCACHED_BEHAVIOR_BUFFER_REQUESTS.--CONFIGURE-FILE=β gives a configuration file to load requests from. β οΈ beware: if you use a configuration file, libmemcached will resetmemcached_stbased on information contained only in that file. it's giving full reset, bestie.--CONNECT-TIMEOUT=β seememcached_behavior_set()forMEMCACHED_BEHAVIOR_CONNECT_TIMEOUT.--DISTRIBUTION=β sets the distribution model the client uses. seememcached_behavior_set()for more details.--HASH=β sets the hashing algorithm used for placing keys on servers.--HASH-WITH-NAMESPACEβ when enabled, the prefix key gets added to the key when figuring out which server the data goes on. iykyk.--NOREPLYβ enables "no reply" for all calls that support it. it is highly recommended that you use this option with the binary protocol only. fr fr, listen to that one.--NUMBER-OF-REPLICAS=β sets how many servers keys get replicated to.--RANDOMIZE-REPLICA-READβ randomly picks the server within the replication pool to read from. main character selection energy π²--SORT-HOSTSβ when adding new servers, always calculates 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 provides context for keys; only other requests that know the namespace can access these values. how? by prepending the namespace value to all keys. iconic little secret club π
π¦ Memcached Pool Options: π¦
--POOL-MINβ initial size of 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=β (yes bestie, that's all she wrote on this one π)--IO-KEY-PREFETCH=β (no description given, just the option itself)--IO-MSG-WATERMARK=β (no description given, just the option itself)--TCP-KEEPIDLEβ (no description given, just the option itself)--RCV-TIMEOUT=β (no description given, just the option itself)
π« Other Options: π«
INCLUDEβ include a file in configuration. unlike--CONFIGURE-FILE=, this will not resetmemcached_st.RESETβ resetmemcached_stand keep processing.ENDβ end configuration processing.ERRORβ end configuration processing and throw an error. dramatic exit, honestly π
π ENVIRONMENT π
LIBMEMCACHED
π RETURN VALUE π
memcached() returns a pointer to the memcached_st that was created (or initialized). but if allocation fails, it returns NULL. π so always check, bestie.
β 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)
okay that's the whole page, you ate it up π this was libmemcached_configuration(3) from libmemcached-awesome, version 1.1, dated Jul 24, 2025. now go forth and configure, periodt π β¨π¦
π¦ 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