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 settings
  • option_string_length β€” the length of options_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 initialized memcached_pool_st instance 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 initialized memcached_pool_st instance
  • relative_time β€” how long to block the thread and wait for a connection to become available when the pool size is exceeded β€” unless it's nullptr, in which case no blocking for you
  • rc β€” an out pointer to memcached_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 initialized memcached_pool_st instance
  • mmc β€” the memcached_st instance 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 initialized memcached_pool_st instance
  • flag β€” the behavior you want to change
  • value β€” the value to set for flag

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 initialized memcached_pool_st instance
  • flag β€” the behavior you want to read
  • value β€” an out pointer that receives the set value of flag

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 returns MEMCACHED_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_ARGUMENTS gets 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