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 string
  • string_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 string
  • length β€” how long the configuration string is, again without any terminating zero
  • error_buffer β€” the buffer where any error message gets stored
  • error_buffer_size β€” how much space the error_buffer actually 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 of 1.
  • --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 of 1.
  • --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 behavior MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS.
  • --BINARY-PROTOCOL β€” forces every connection to use the binary protocol.
  • --BUFFER-REQUESTS β€” please see MEMCACHED_BEHAVIOR_BUFFER_REQUESTS.
  • --CONFIGURE-FILE= β€” gives a configuration file to load requests from. ⚠️ beware: if you use a configuration file, libmemcached will reset memcached_st based on information contained only in that file. it's giving full reset, bestie.
  • --CONNECT-TIMEOUT= β€” see memcached_behavior_set() for MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT.
  • --DISTRIBUTION= β€” sets the distribution model the client uses. see memcached_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 β€” see memcached_behavior_set() for MEMCACHED_BEHAVIOR_SUPPORT_CAS.
  • --USE-UDP β€” see memcached_behavior_set() for MEMCACHED_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 β€” see memcached_behavior_set() for MEMCACHED_BEHAVIOR_TCP_NODELAY.
  • --TCP-KEEPALIVE β€” see memcached_behavior_set() for MEMCACHED_BEHAVIOR_TCP_KEEPALIVE.
  • --RETRY-TIMEOUT= β€” see memcached_behavior_set() for MEMCACHED_BEHAVIOR_RETRY_TIMEOUT.
  • --SERVER-FAILURE-LIMIT= β€” see memcached_behavior_set() for MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT.
  • --SND-TIMEOUT= β€” see memcached_behavior_set() for MEMCACHED_BEHAVIOR_SND_TIMEOUT.
  • --SOCKET-RECV-SIZE= β€” see memcached_behavior_set() for MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE.
  • --SOCKET-SEND-SIZE= β€” see memcached_behavior_set() for MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE.
  • --POLL-TIMEOUT= β€” sets the timeout used by poll(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 reset memcached_st.
  • RESET β€” reset memcached_st and 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