---
name: "libmemcached_configuration"
section: "3"
platform: "linux"
package: "libmemcached-awesome"
version: "1.1.4-4"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libmemcached_configuration"
---

# libmemcached\_configuration(3)

libmemcached Documentation

## NAME

libmemcached\_configuration - libmemcached Documentation

## SYNOPSIS

- **#include \<libmemcached-1.0/memcached.h\>**

  Compile and link with -lmemcached

- **memcached\_st \<#\_CPPv412memcached\_st\> \*memcached(const char \*string, size\_t string\_length)**

  - **Parameters**

    - •

      **string** -- configuration string

    - •

      **string\_length** -- length of the configuration string without any terminating zero

  - **Returns**

    allocated and initialized **memcached\_st** \<#\_CPPv412memcached\_st\> struct

- **memcached\_return\_t \<#\_CPPv418memcached\_return\_t\> libmemcached\_check\_configuration(const char \*option\_string, size\_t length, char \*error\_buffer, size\_t error\_buffer\_size)**

  - **Parameters**

    - •

      **option\_string** -- configuration string

    - •

      **length** -- length of the configuration string without any terminating zero

    - •

      **error\_buffer** -- buffer used to store any error message

    - •

      **error\_buffer\_size** -- available size of the **error\_buffer**

  - **Returns**

    **memcached\_return\_t** \<#\_CPPv418memcached\_return\_t\> indicating success

## DESCRIPTION

**libmemcached** implements a custom language for configuring and modifying servers. By passing in an option string you can generate a **memcached\_st** \<#\_CPPv412memcached\_st\> object that you can use in your application directly.

### General Options:

- **--SERVER=\<servername\>:\<optional\_port\>/?\<optional\_weight\>**

  Provide a servername to be used by the client.

  Providing a weight will cause weighting to occur with all hosts with each server getting a default weight of 1.

- **--SOCKET=\\"\<filepath\>/?\<optional\_weight\>\\"**

  Provide a filepath to a UNIX socket file. Providing a weight will cause weighting to occur with all hosts with each server getting a default weight of 1.

- **--VERIFY-KEY**

  Verify that keys that are being used fit within the design of the protocol being used.

- **--REMOVE\_FAILED\_SERVERS**

  Enable the behavior **MEMCACHED\_BEHAVIOR\_REMOVE\_FAILED\_SERVERS** \<#\_CPPv4N20memcached\_behavior\_t40MEMCACHED\_BEHAVIOR\_REMOVE\_FAILED\_SERVERSE\>.

- **--BINARY-PROTOCOL**

  Force all connections to use the binary protocol.

- **--BUFFER-REQUESTS**

  Please see **MEMCACHED\_BEHAVIOR\_BUFFER\_REQUESTS** \<#\_CPPv4N20memcached\_behavior\_t34MEMCACHED\_BEHAVIOR\_BUFFER\_REQUESTSE\>.

- **--CONFIGURE-FILE=**

  Provide a configuration file to be used to load requests. Beware that by using a configuration file **libmemcached** will reset **memcached\_st** \<#\_CPPv412memcached\_st\> based on information only contained in the file.

- **--CONNECT-TIMEOUT=**

  See **memcached\_behavior\_set()** \<#\_CPPv422memcached\_behavior\_setP12memcached\_st20memcached\_behavior\_t8uint64\_t\> for **MEMCACHED\_BEHAVIOR\_CONNECT\_TIMEOUT** \<#\_CPPv4N20memcached\_behavior\_t34MEMCACHED\_BEHAVIOR\_CONNECT\_TIMEOUTE\>.

- **--DISTRIBUTION=**

  Set the distribution model used by the client. See **memcached\_behavior\_set()** \<#\_CPPv422memcached\_behavior\_setP12memcached\_st20memcached\_behavior\_t8uint64\_t\> for more details.

- **--HASH=**

  Set the hashing algorithm used for placing keys on servers.

- **--HASH-WITH-NAMESPACE**

  When enabled the prefix key will be added to the key when determining which server to store the data in.

- **--NOREPLY**

  Enable "no reply" for all calls that support this. It is highly recommended that you use this option with the binary protocol only.

- **--NUMBER-OF-REPLICAS=**

  Set the number of servers that keys will be replicated to.

- **--RANDOMIZE-REPLICA-READ**

  Select randomly the server within the replication pool to read from.

- **--SORT-HOSTS**

  When adding new servers always calculate their distribution based on sorted naming order.

- **--SUPPORT-CAS**

  See **memcached\_behavior\_set()** \<#\_CPPv422memcached\_behavior\_setP12memcached\_st20memcached\_behavior\_t8uint64\_t\> for **MEMCACHED\_BEHAVIOR\_SUPPORT\_CAS** \<#\_CPPv4N20memcached\_behavior\_t30MEMCACHED\_BEHAVIOR\_SUPPORT\_CASE\>

- **--USE-UDP**

  See **memcached\_behavior\_set()** \<#\_CPPv422memcached\_behavior\_setP12memcached\_st20memcached\_behavior\_t8uint64\_t\> for **MEMCACHED\_BEHAVIOR\_USE\_UDP** \<#\_CPPv4N20memcached\_behavior\_t26MEMCACHED\_BEHAVIOR\_USE\_UDPE\>

- **--NAMESPACE=**

  A namespace is a container that provides context for keys, only other requests that know the namespace can access these values. This is accomplished by prepending the namespace value to all keys.

### 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()** \<#\_CPPv422memcached\_behavior\_setP12memcached\_st20memcached\_behavior\_t8uint64\_t\> for **MEMCACHED\_BEHAVIOR\_TCP\_NODELAY** \<#\_CPPv4N20memcached\_behavior\_t30MEMCACHED\_BEHAVIOR\_TCP\_NODELAYE\>

- **--TCP-KEEPALIVE**

  See **memcached\_behavior\_set()** \<#\_CPPv422memcached\_behavior\_setP12memcached\_st20memcached\_behavior\_t8uint64\_t\> for **MEMCACHED\_BEHAVIOR\_TCP\_KEEPALIVE**

- **--RETRY-TIMEOUT=**

  See **memcached\_behavior\_set()** \<#\_CPPv422memcached\_behavior\_setP12memcached\_st20memcached\_behavior\_t8uint64\_t\> for **MEMCACHED\_BEHAVIOR\_RETRY\_TIMEOUT** \<#\_CPPv4N20memcached\_behavior\_t32MEMCACHED\_BEHAVIOR\_RETRY\_TIMEOUTE\>

- **--SERVER-FAILURE-LIMIT=**

  See **memcached\_behavior\_set()** \<#\_CPPv422memcached\_behavior\_setP12memcached\_st20memcached\_behavior\_t8uint64\_t\> for **MEMCACHED\_BEHAVIOR\_SERVER\_FAILURE\_LIMIT** \<#\_CPPv4N20memcached\_behavior\_t39MEMCACHED\_BEHAVIOR\_SERVER\_FAILURE\_LIMITE\>

- **--SND-TIMEOUT=**

  See **memcached\_behavior\_set()** \<#\_CPPv422memcached\_behavior\_setP12memcached\_st20memcached\_behavior\_t8uint64\_t\> for **MEMCACHED\_BEHAVIOR\_SND\_TIMEOUT** \<#\_CPPv4N20memcached\_behavior\_t30MEMCACHED\_BEHAVIOR\_SND\_TIMEOUTE\>

- **--SOCKET-RECV-SIZE=**

  See **memcached\_behavior\_set()** \<#\_CPPv422memcached\_behavior\_setP12memcached\_st20memcached\_behavior\_t8uint64\_t\> for **MEMCACHED\_BEHAVIOR\_SOCKET\_RECV\_SIZE** \<#\_CPPv4N20memcached\_behavior\_t35MEMCACHED\_BEHAVIOR\_SOCKET\_RECV\_SIZEE\>

- **--SOCKET-SEND-SIZE=**

  See **memcached\_behavior\_set()** \<#\_CPPv422memcached\_behavior\_setP12memcached\_st20memcached\_behavior\_t8uint64\_t\> for **MEMCACHED\_BEHAVIOR\_SOCKET\_SEND\_SIZE** \<#\_CPPv4N20memcached\_behavior\_t35MEMCACHED\_BEHAVIOR\_SOCKET\_SEND\_SIZEE\>

- **--POLL-TIMEOUT=**

  Set the timeout used by **poll(3) \<https://linux.die.net/man/3/poll\>**.

- **--IO-BYTES-WATERMARK=**

  - **--IO-KEY-PREFETCH=**

  - **--IO-MSG-WATERMARK=**

  - **--TCP-KEEPIDLE**

  - **--RCV-TIMEOUT=**

  ### Other Options:

- **INCLUDE**

  Include a file in configuration. Unlike **--CONFIGURE-FILE=** this will not reset **memcached\_st** \<#\_CPPv412memcached\_st\>.

- **RESET**

  Reset **memcached\_st** \<#\_CPPv412memcached\_st\> and continue to process.

- **END**

  End configuration processing.

- **ERROR**

  End configuration processing and throw an error.

## ENVIRONMENT

- **LIBMEMCACHED**

  ## RETURN VALUE

**memcached()** returns a pointer to the **memcached\_st** \<#\_CPPv412memcached\_st\> that was created (or initialized).  On an allocation failure, it returns NULL.

## 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)](/memcached/1.md) \<https://linux.die.net/man/1/memcached\>** **[libmemcached(3)](/libmemcached/3.md) \<https://linux.die.net/man/3/libmemcached\>** **[memcached\_strerror(3)](/memcached_strerror/3.md) \<https://linux.die.net/man/3/memcached\_strerror\>**
