---
name: "memcached_pool_pop"
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/memcached_pool_pop"
---

# memcached\_pool\_pop(3)

libmemcached Documentation

## NAME

memcached\_pool\_pop - libmemcached Documentation

## SYNOPSIS

- **#include \<libmemcachedutil-1.0/pool.h\>**

  Compile and link with -lmemcachedutil -lmemcached

- **typedef struct memcached\_pool\_st memcached\_pool\_st**

  - **memcached\_pool\_st \*memcached\_pool(const char \*option\_string, size\_t option\_string\_length)**

  - **Parameters**

    - •

      **option\_string** -- configuration \<\> string

    - •

      **option\_string\_length** -- length of **options\_string** without any trailing zero byte

  - **Returns**

    allocated and initialized **memcached\_pool\_st** instance on success or nullptr on failure

- **memcached\_st \<#\_CPPv412memcached\_st\> \*memcached\_pool\_destroy(memcached\_pool\_st \*pool)**

  - **Parameters**

    **pool** -- initialized **memcached\_pool\_st** instance to free

  - **Returns**

    pointer to the 'master' **memcached\_st** \<#\_CPPv412memcached\_st\> instance by legacy

- **memcached\_st \<#\_CPPv412memcached\_st\> \*memcached\_pool\_fetch(memcached\_pool\_st \*pool, struct timespec \*relative\_time, memcached\_return\_t \<#\_CPPv418memcached\_return\_t\> \*rc)**

  Added in version 0.53: Synonym for memcached\_pool\_pop

  - **Parameters**

    - •

      **pool** -- initialized **memcached\_pool\_st** instance

    - •

      **relative\_time** -- time to block thread and wait for a connection to become available when pool size is exceeded, unless nullptr

    - •

      **rc** -- out pointer to **memcached\_return\_t** \<#\_CPPv418memcached\_return\_t\>

  - **Returns**

    pointer to an available **memcached\_st** \<#\_CPPv412memcached\_st\> instance

- **memcached\_return\_t \<#\_CPPv418memcached\_return\_t\> memcached\_pool\_release(memcached\_pool\_st \*pool, memcached\_st \<#\_CPPv412memcached\_st\> \*mmc)**

  Added in version 0.53: Synonym for memcached\_pool\_push.

  - **Parameters**

    - •

      **pool** -- initialized **memcached\_pool\_st** instance

    - •

      **mmc** -- the **memcached\_st** \<#\_CPPv412memcached\_st\> instance to return to the pool

  - **Returns**

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

- **memcached\_return\_t \<#\_CPPv418memcached\_return\_t\> memcached\_pool\_behavior\_set(memcached\_pool\_st \*pool, memcached\_behavior\_t \<#\_CPPv420memcached\_behavior\_t\> flag, uint64\_t data)**

  - **Parameters**

    - •

      **pool** -- initialized **memcached\_pool\_st** instance

    - •

      **flag** -- the behavior \<\> to change

    - •

      **value** -- the value to set for **flag**

  - **Returns**

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

- **memcached\_return\_t \<#\_CPPv418memcached\_return\_t\> memcached\_pool\_behavior\_get(memcached\_pool\_st \*pool, memcached\_behavior\_t \<#\_CPPv420memcached\_behavior\_t\> flag, uint64\_t \*value)**

  - **Parameters**

    - •

      **pool** -- initialized **memcached\_pool\_st** instance

    - •

      **flag** -- the behavior \<\> to read

    - •

      **value** -- out pointer to receive the set value of **flag**

  - **Returns**

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

- **memcached\_pool\_st \*memcached\_pool\_create(memcached\_st \<#\_CPPv412memcached\_st\> \*mmc, int initial, int max)**

  Deprecated since version 0.46: Use **memcached\_pool()**

- **memcached\_st \<#\_CPPv412memcached\_st\> \*memcached\_pool\_pop(memcached\_pool\_st \*pool, bool block, memcached\_return\_t \<#\_CPPv418memcached\_return\_t\> \*rc)**

  Deprecated since version 0.53: Use **memcached\_pool\_fetch()**

- **memcached\_return\_t \<#\_CPPv418memcached\_return\_t\> memcached\_pool\_push(memcached\_pool\_st \*pool, memcached\_st \<#\_CPPv412memcached\_st\> \*mmc)**

  Deprecated since version 0.53: Use **memcached\_pool\_release()**

## DESCRIPTION

**memcached\_pool()** is used to create a connection pool of objects you may use to remove the overhead of using memcached\_clone for short lived **memcached\_st** \<#\_CPPv412memcached\_st\> objects. Please see libmemcached Configuration \<\> for details on the format of the configuration string.

**memcached\_pool\_destroy()** is used to destroy the connection pool created with **memcached\_pool\_create()** and release all allocated resources. It will return the pointer to the **memcached\_st** \<#\_CPPv412memcached\_st\> structure passed as an argument to **memcached\_pool\_create()**, and returns the ownership of the pointer to the caller when created with **memcached\_pool\_create()**, otherwise NULL is returned..

**memcached\_pool\_fetch()** is used to fetch a connection structure from the connection pool. The relative\_time argument specifies if the function should block and wait for a connection structure to be available if we try to exceed the maximum size. You need to specify time in relative time.

**memcached\_pool\_release()** is used to return a connection structure back to the pool.

**memcached\_pool\_behavior\_get()** and **memcached\_pool\_behavior\_set()** is used to get/set behavior flags on all connections in the pool.

Both **memcached\_pool\_release()** and **memcached\_pool\_fetch()** are thread safe.

## RETURN VALUE

**memcached\_pool\_destroy()** returns the pointer (and ownership) to the **memcached\_st** \<#\_CPPv412memcached\_st\> structure used to create the pool. If connections are in use it returns NULL.

**memcached\_pool\_pop()** returns a pointer to a **memcached\_st** \<#\_CPPv412memcached\_st\> structure from the pool (or NULL if an allocation cannot be satisfied).

**memcached\_pool\_release()** returns **MEMCACHED\_SUCCESS** \<#\_CPPv4N18memcached\_return\_t17MEMCACHED\_SUCCESSE\> upon success.

**memcached\_pool\_behavior\_get()** and **memcached\_pool\_behavior\_get()** return **MEMCACHED\_SUCCESS** \<#\_CPPv4N18memcached\_return\_t17MEMCACHED\_SUCCESSE\> upon success.

**memcached\_pool\_fetch()** may return **MEMCACHED\_TIMEOUT** \<#\_CPPv4N18memcached\_return\_t17MEMCACHED\_TIMEOUTE\> if a timeout occurs while waiting for a free **memcached\_st** \<#\_CPPv412memcached\_st\> instance, **MEMCACHED\_NOTFOUND** \<#\_CPPv4N18memcached\_return\_t18MEMCACHED\_NOTFOUNDE\> if no **memcached\_st** \<#\_CPPv412memcached\_st\> instance was available, respectively.

**Note:**

If any method returns **MEMCACHED\_IN\_PROGRESS** then a lock on the pool could not be obtained.

If any of the parameters passed to any of these functions is invalid, **MEMCACHED\_INVALID\_ARGUMENTS** \<#\_CPPv4N18memcached\_return\_t27MEMCACHED\_INVALID\_ARGUMENTSE\> will be returned.

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