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, queen
  • string_length β€” how long that configuration string is, without any terminating zero (no sneaky \0 counted, 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 string
  • length β€” length of the configuration string, again without any terminating zero
  • error_buffer β€” the buffer where any error message gets stored
  • error_buffer_size β€” how much room the error_buffer actually 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 behavior MEMCACHED_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 at MEMCACHED_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 reset memcached_st based on information that's only contained in that file. your old settings? gone. 😭
  • --CONNECT-TIMEOUT= β€” see memcached_behavior_set() for MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT.
  • --DISTRIBUTION= β€” sets the distribution model the client uses. see memcached_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 β€” 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 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 β€” 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= β€” 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 reset memcached_st. huge difference, don't mix them up 🫢
  • RESET β€” resets memcached_st and 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