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 pool
  • option_string_length β€” how long options_string is, 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 initialized memcached_pool_st instance 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 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
  • rc β€” out pointer to a 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 β€” the initialized memcached_pool_st instance
  • mmc β€” the memcached_st instance 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 initialized memcached_pool_st instance
  • flag β€” the behavior you wanna 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 β€” the initialized memcached_pool_st instance
  • flag β€” the behavior you wanna read
  • value β€” out pointer that receives the set value of flag

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