MEMCACHED_POOL_PUSH(3)
π NAME π
okay so bestie, this is the page for memcached_pool_push β it's part of libmemcached-awesome's documentation, and it's your whole cheat sheet for the connection-pool era of libmemcached. lowkey iconic. π
β¨ SYNOPSIS β¨
first things first, the includes and the linker flags, copy these exactly or nothing works, fr fr:
#include <libmemcachedutil-1.0/pool.h>
Compile and link with -lmemcachedutil -lmemcached
and here's the opaque type you'll be passing around everywhere:
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, like the whole vibe spec for your pooloption_string_lengthβ how longoptions_stringis, and NOT counting any trailing zero byte
Returns β a freshly allocated and initialized memcached_pool_st instance when it slays, or nullptr when it doesn't π
π¦ memcached_pool_destroy
memcached_st *memcached_pool_destroy(memcached_pool_st *pool)
Parameters
poolβ the initializedmemcached_pool_stinstance you wanna free
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: synonym for memcached_pool_pop. yes bestie it's the same thing, they just gave it a glow-up β¨
Parameters
poolβ the 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'snullptrrcβ out pointer to amemcached_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β the initializedmemcached_pool_stinstancemmcβ thememcached_stinstance you're handing back to the pool
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β the initializedmemcached_pool_stinstanceflagβ the behavior you wanna 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β the initializedmemcached_pool_stinstanceflagβ the behavior you wanna readvalueβ out pointer that receives the set value offlag
Returns β a memcached_return_t indicating success
π₯ memcached_pool_create
memcached_pool_st *memcached_pool_create(memcached_st *mmc, int initial,
int max)
Deprecated since version 0.46: use memcached_pool() instead. not me telling you to move on π
π₯ memcached_pool_pop
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
memcached_return_t memcached_pool_push(memcached_pool_st *pool,
memcached_st *mmc)
Deprecated since version 0.53: use memcached_pool_release() instead. yeah this page is literally named after the deprecated one, we don't make the rules π
π«Ά DESCRIPTION π«Ά
okay so memcached_pool() creates a connection pool of objects, and the whole point is to remove the overhead of using memcached_clone for short lived memcached_st objects. if you want the tea on the configuration string format, 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 you β but only when it was created with memcached_pool_create(). otherwise NULL is returned.
memcached_pool_fetch() fetches a connection structure out of the connection pool. the relative_time argument is what decides whether the function should block and wait for a connection structure to become available if we try to exceed the maximum size. and yes, you need to specify that time in relative time. β³
memcached_pool_release() gives a connection structure back to the pool. be nice, return your toys π§Έ
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 big one: 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 structure that was 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_release() returns MEMCACHED_SUCCESS upon success.
memcached_pool_behavior_get() and memcached_pool_behavior_get() return MEMCACHED_SUCCESS upon success.
memcached_pool_fetch() may return MEMCACHED_TIMEOUT if a timeout occurs 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, then 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_ARGUMENTSwill be returned.
π SEE ALSO π
and that's the whole page bestie, you ate π β¨ this was libmemcached-awesome, version 1.1, dated Jul 24, 2025 β go forth and pool responsibly π¦π
π¦ 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