MEMCACHED_POOL_BEHAVIOR_GET(3)
π MEMCACHED_POOL_BEHAVIOR_GET π
okay so bestie, this one lives in section 3 of the libmemcached-awesome manual, and its full glow-up name is MEMCACHED_P...BEHAVIOR_GET(3). It's all about the β¨connection poolβ¨ β the little clique of memcached_st objects you keep around so you don't have to keep making new friends. Let's get into it π«Ά
πΈ NAME πΈ
memcached_pool_behavior_get β libmemcached Documentation
β¨ SYNOPSIS β¨
#include <libmemcachedutil-1.0/pool.h>
Compile and link with -lmemcachedutil -lmemcached
typedef struct memcached_pool_st memcached_pool_st
π¦ memcached_pool_st *memcached_pool(const char *option_string, size_t option_string_length)
Parameters
option_stringβ configuration stringoption_string_lengthβ length ofoptions_stringwithout any trailing zero byte
Returns
allocated and initialized memcached_pool_st instance on success or nullptr on failure
π¦ memcached_st *memcached_pool_destroy(memcached_pool_st *pool)
Parameters
poolβ initializedmemcached_pool_stinstance to free
Returns
pointer to the 'master' memcached_st instance by legacy
π¦ memcached_st *memcached_pool_fetch(memcached_pool_st *pool, struct timespec *relative_time, memcached_return_t *rc)
Added in version 0.53 β it's a synonym for memcached_pool_pop π
Parameters
poolβ initializedmemcached_pool_stinstancerelative_timeβ time to block thread and wait for a connection to become available when pool size is exceeded, unlessnullptrrcβ out pointer tomemcached_return_t
Returns
pointer to an available memcached_st instance
π¦ 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β initializedmemcached_pool_stinstancemmcβ thememcached_stinstance to return to the pool
Returns
memcached_return_t indicating success
π¦ memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool, memcached_behavior_t flag, uint64_t data)
Parameters
poolβ initializedmemcached_pool_stinstanceflagβ the behavior to changevalueβ the value to set forflag
Returns
memcached_return_t indicating success
π¦ memcached_return_t memcached_pool_behavior_get(memcached_pool_st *pool, memcached_behavior_t flag, uint64_t *value)
Parameters
poolβ initializedmemcached_pool_stinstanceflagβ the behavior to readvalueβ out pointer to receive the set value offlag
Returns
memcached_return_t indicating success
π¦ memcached_pool_st *memcached_pool_create(memcached_st *mmc, int initial, int max)
Deprecated since version 0.46 β use memcached_pool() instead π
π¦ 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_return_t memcached_pool_push(memcached_pool_st *pool, memcached_st *mmc)
Deprecated since version 0.53 β use memcached_pool_release() instead π
π DESCRIPTION π
memcached_pool() is the one that creates the connection pool, and the whole point is to skip the overhead of using memcached_clone for short lived memcached_st objects. For the deets on how the configuration string is formatted, go peek at libmemcached Configuration π
memcached_pool_destroy() destroys the connection pool that was created with memcached_pool_create() and releases all the allocated resources. It hands you back the pointer to the memcached_st structure that was passed as an argument to memcached_pool_create(), and it returns the ownership of that pointer to the caller when created with memcached_pool_create() β otherwise NULL is returned.. (yes, two dots, we don't make the rules π
)
memcached_pool_fetch() grabs a connection structure out of the connection pool. The relative_time argument is the vibe check for whether the function should block and wait for a connection structure to become available when you try to exceed the maximum size. Heads up: you need to specify time in relative time β³
memcached_pool_release() gives a connection structure back to the pool, like returning a borrowed hoodie π§₯
memcached_pool_behavior_get() and memcached_pool_behavior_set() get/set behavior flags on all connections in the pool. All of them. Every single one. periodt.
Both memcached_pool_release() and memcached_pool_fetch() are thread safe π
β RETURN VALUE β
memcached_pool_destroy() returns the pointer (and the ownership) to the memcached_st structure used to create the pool. And if connections are still in use? It returns NULL, no cap.
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. (not me pointing out it says _get twice β that's literally what the page says, iykyk π)
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_PROGRESSthen a lock on the pool could not be obtained. π¨ If any of the parameters passed to any of these functions is invalid,MEMCACHED_INVALID_ARGUMENTSwill be returned.
π SEE ALSO π
memcached(1) libmemcached(3) libmemcached_configuration(3) β memcached_strerror(3)
and that's the whole page, bestie π this was libmemcached-awesome, version 1.1, dated Jul 24, 2025 β go forth and pool responsibly, you've got this fr fr πΈπ¦β¨
π¦ 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