MEMCACHED_POOL_RELEASE(3)
π MEMCACHED_POOL_RELEASE π
okay so bestie, this is the memcached_pool_release(3) page from libmemcached-awesome β it's the whole connection-pool saga, and honestly? it ate. pools, fetch, release, behaviors, deprecated stuff, all of it. let's go π«Ά
β¨ NAME β¨
memcached_pool_release β libmemcached Documentation (yes that's literally all the NAME section says, we don't make the rules π
)
β¨ SYNOPSIS β¨
first up, the include and the link, and you have to do both or nothing works:
#include <libmemcachedutil-1.0/pool.h>
Compile and link with -lmemcachedutil -lmemcached
and here's the opaque type, she's mysterious, she's a struct you never peek inside:
typedef struct memcached_pool_st memcached_pool_st
πΈ memcached_pool
memcached_pool_st *memcached_pool(const char *option_string, size_t
option_string_length)
Parameters
option_stringβ the configuration string, aka the vibe settingsoption_string_lengthβ the length ofoptions_string, and no trailing zero byte allowed, so don't count the NUL
Returns
a fully allocated and initialized memcached_pool_st instance if it worked, or nullptr if it flopped π
πΈ memcached_pool_destroy
memcached_st *memcached_pool_destroy(memcached_pool_st *pool)
Parameters
poolβ an initializedmemcached_pool_stinstance that you want freed
Returns
a pointer to the 'master' memcached_st instance by legacy π
πΈ memcached_pool_fetch
memcached_st *memcached_pool_fetch(memcached_pool_st *pool, struct
timespec *relative_time, memcached_return_t *rc)
Added in version 0.53: she's a synonym for memcached_pool_pop β¨
Parameters
poolβ an initializedmemcached_pool_stinstancerelative_timeβ how long to block the thread and wait for a connection to become available when the pool size is exceeded β unless it'snullptr, in which case no blocking for yourcβ an out pointer tomemcached_return_t
Returns
a pointer to an available memcached_st instance π
πΈ memcached_pool_release
memcached_return_t memcached_pool_release(memcached_pool_st *pool,
memcached_st *mmc)
Added in version 0.53: synonym for memcached_pool_push π«
Parameters
poolβ an initializedmemcached_pool_stinstancemmcβ thememcached_stinstance you're giving back to the pool, like returning a library book bestie
Returns
a memcached_return_t indicating success π«Ά
πΈ memcached_pool_behavior_set
memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool,
memcached_behavior_t flag, uint64_t data)
Parameters
poolβ an initializedmemcached_pool_stinstanceflagβ the behavior you want to changevalueβ the value to set forflag
Returns
a memcached_return_t indicating success β¨
πΈ memcached_pool_behavior_get
memcached_return_t memcached_pool_behavior_get(memcached_pool_st *pool,
memcached_behavior_t flag, uint64_t *value)
Parameters
poolβ an initializedmemcached_pool_stinstanceflagβ the behavior you want to readvalueβ an out pointer that receives the set value offlag
Returns
a memcached_return_t indicating success π
πΈ memcached_pool_create (the old one)
memcached_pool_st *memcached_pool_create(memcached_st *mmc, int initial,
int max)
Deprecated since version 0.46: use memcached_pool() instead, bestie. she's retired π
πΈ memcached_pool_pop (also old)
memcached_st *memcached_pool_pop(memcached_pool_st *pool, bool block,
memcached_return_t *rc)
Deprecated since version 0.53: use memcached_pool_fetch() instead π
πΈ memcached_pool_push (old too, sorry)
memcached_return_t memcached_pool_push(memcached_pool_st *pool,
memcached_st *mmc)
Deprecated since version 0.53: use memcached_pool_release() instead π
β¨ DESCRIPTION β¨
okay so here's the actual tea β
memcached_pool() creates a connection pool of objects, and you use it to get rid of the overhead of calling memcached_clone for short lived memcached_st objects. like, stop doing that, the pool is right there. if you want the deets on how the configuration string is formatted, go read libmemcached Configuration π
memcached_pool_destroy() destroys the connection pool that was created with memcached_pool_create() and releases all the allocated resources. it returns the pointer to the memcached_st structure that was passed as an argument to memcached_pool_create(), and it hands the ownership of that pointer back to the caller when the pool was created with memcached_pool_create() β otherwise NULL is returned.. (yes there are two periods at the end, that's canon, I don't make the rules π
)
memcached_pool_fetch() fetches a connection structure from the connection pool. the relative_time argument decides whether the function should block and wait for a connection structure to become available if we're trying to exceed the maximum size. and heads up β you have to specify the time in relative time, not absolute, okurrr β°
memcached_pool_release() returns a connection structure back to the pool. give her back, she's not yours π«Ά
memcached_pool_behavior_get() and memcached_pool_behavior_set() get and set behavior flags on all the connections in the pool. every single one. no cap. π
and the important one: both memcached_pool_release() and memcached_pool_fetch() are thread safe β¨ (iconic behavior, honestly)
β¨ RETURN VALUE β¨
memcached_pool_destroy() returns the pointer (and the ownership) to the memcached_st structure that was used to create the pool. if connections are in use, it returns NULL. so rude but okay π
memcached_pool_pop() returns a pointer to a memcached_st structure from the pool β or NULL if an allocation cannot be satisfied.
memcached_pool_release() returns MEMCACHED_SUCCESS upon success. slay.
memcached_pool_behavior_get() and memcached_pool_behavior_get() return MEMCACHED_SUCCESS upon success. (and yes bestie, the manpage literally writes memcached_pool_behavior_get() twice β we're keeping it exactly as written, character for character, that's the assignment π)
memcached_pool_fetch() may return MEMCACHED_TIMEOUT if a timeout happens while waiting for a free memcached_st instance, or MEMCACHED_NOTFOUND if no memcached_st instance was available, respectively.
NOTE: if any method returnsMEMCACHED_IN_PROGRESS, that means a lock on the pool could not be obtained. π and if any of the parameters passed to any of these functions is invalid,MEMCACHED_INVALID_ARGUMENTSgets returned. π«
β¨ SEE ALSO β¨
memcached(1) libmemcached(3) libmemcached_configuration(3) β memcached_strerror(3)
(that little dash in the middle is a real character, not a hyphen, we don't ask questions πΈ)
and that's the whole page bestie, you're basically a pool expert now π β¨
libmemcached-awesome, version 1.1 β dated Jul 24, 2025 π bye mwah π«Ά
π¦ where this page comes from
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms