---
name: "Memcached::libmemcached::memcached_pool"
section: "3pm"
platform: "linux"
package: "libmemcached-libmemcached-perl"
version: "1.001801+dfsg-5+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Memcached::libmemcached::memcached_pool"
---

# Memcached::libmemcached::memcached\_pool(3pm)

Manage pools

## NAME

memcached\_pool\_create, memcached\_pool\_destroy, memcached\_pool\_push, memcached\_pool\_pop - Manage pools

## LIBRARY

C Client Library for memcached (libmemcachedutil, -lmemcachedutil)

## SYNOPSIS

```
  #include <libmemcached/memcached_pool.h>
  memcached_pool_st *
    memcached_pool_create(memcached_st* mmc, int initial, int max);
  memcached_st *
    memcached_pool_destroy(memcached_pool_st* pool);
  memcached_st *
    memcached_pool_pop (memcached_pool_st* pool, bool block, memcached_return_t *rc);
  memcached_return_t
    memcached_pool_push(memcached_pool_st* pool, memcached_st *mmc);
  memcached_st *memcached_create (memcached_st *ptr);
  memcached_return_t
    memcached_pool_behavior_set(memcached_pool_st *pool,
                                memcached_behavior_t flag,
                                uint64_t data)
  memcached_return_t
    memcached_pool_behavior_get(memcached_pool_st *pool,
                                memcached_behavior_t flag,
                                uint64_t *value)
```

## DESCRIPTION

**memcached\_pool\_create()** 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"` objects. The mmc argument should be an initialised `"memcached_st"` structure, and a successfull invocation of memcached\_pool\_create takes full ownership of the variable (until it is released by memcached\_pool\_destroy). The `"initial"` argument specifies the initial size of the connection pool, and the `"max"` argument specifies the maximum size the connection pool should grow to. Please note that the library will allocate a fixed size buffer scaled to the max size of the connection pool, so you should not pass MAXINT or some other large number here.

**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"` structure passed as an argument to **memcached\_pool\_create()**, and returns the ownership of the pointer to the caller.

**memcached\_pool\_pop()** is used to grab a connection structure from the connection pool. The block argument specifies if the function should block and wait for a connection structure to be available if we try to exceed the maximum size.

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

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

## RETURN

**memcached\_pool\_create()** returns a pointer to the newly created memcached\_pool\_st structure. On an allocation failure, it returns NULL.

**memcached\_pool\_destroy()** returns the pointer (and ownership) to the memcached\_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 structure from the pool (or NULL if an allocation cannot be satisfied).

**memcached\_pool\_push()** returns MEMCACHED\_SUCCESS upon success.

**memcached\_pool\_behavior\_get()** and **memcached\_pool\_behavior\_get()** returns MEMCACHED\_SUCCESS upon success.

## HOME

To find out more information please check: \<https://launchpad.net/libmemcached\>

## AUTHOR

Trond Norbye, \<trond.norbye@gmail.com\>

## SEE ALSO

[**memcached**(1)](/memcached/1.md) [**libmemcached**(3)](/libmemcached/3.md) [**memcached\_create**(3)](/memcached_create/3.md) [**memcached\_free**(3)](/memcached_free/3.md) [**libmemcachedutil**(3)](/libmemcachedutil/3.md) [**memcached\_behavior\_get**(3)](/memcached_behavior_get/3.md) [**memcached\_behavior\_set**(3)](/memcached_behavior_set/3.md)
